title: html javascript variable from text input null
body: <p>So basically I'm trying to get a name that is entered in a text input box in the body to show in an alert in script but it always displays the name as null or if I put .value on the end of the document.getElementById("name") it doesn't display anything. I'm confused because in all the tutorials I've seen it always says to just do it like I did it...</p>
  
  <p>Here's the code I was using:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;script&gt;
  var name = document.getElementById("name");
  function showName()
  {
  alert ("Your name: " + name)
  }
  &lt;/script&gt;
  &lt;body&gt;
  &lt;form name = "form"&gt;
  Please enter your full name &lt;input type = "text" id = "name"&gt;&lt;br&gt;
  &lt;input type = "button" value = "show name" onclick = "showName()"&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>