title: Javascript - User input through HTML input tag to set a Javascript variable?
body: <p>I want there to be a textbox on my screen(like the one i'm typing in now) that you can type in then click a submit button and it sends whatever you typed in the box to javascript and javascript prints it out.Here is my code This is the part that works.</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
      &lt;input type="text" id="userInput"=&gt;give me input&lt;/input&gt;
      &lt;button onclick="test()"&gt;Submit&lt;/button&gt;
      &lt;script&gt;
          function test()
          {
              var userInput = document.getElementById("userInput").value;
              document.write(userInput);
          }
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>OK so that's nice, but lets say I want input from that textbox and button while I'm already in a function and don't want to restart the function?</p>
  
  <p>Thanks, 
  Jake</p>