title: Catching value of text box using JavaScript
body: <p>I'm trying to have a button and text box displayed. Have the user enter a number. That a random number will be generated and the user has 10 attempts to answer the question correctly. The script should check whether the users number is either equal to, less than, or greater than the random number. I am having trouble getting the number inputted from the text-box.   </p>
  
  <p>HTML: </p>
  
  <pre><code>&lt;form name="myForm"&gt;
          &lt;div id='myForm'&gt;&lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JAVASCRIPT:</p>
  
  <pre><code>   function partC(){
              var guessCount = 10;
              var random = Math.round(Math.random()*100);
  
              var button = document.createElement('input');
              button.type = "button";
              button.value = " Guess! ";
              document.getElementById('myForm').appendChild(button);
              var textbox = document.createElement('input');
              textbox.type = 'number';
              document.getElementById('myForm').appendChild(textbox);
              var check = document.getElementById('textbox').value
              button.onclick = calc(guessCount, random, check);
  
      }
  
      function calc(guessCount, random, check){
          while(guessCount &gt; 0) {
                  if (check == random){
                      alert("Correct!");
                  } else if (check &gt; random) {
                      alert("Try Again. Guess to High. " + guessCount + " tries left.");
                  } else if (check &lt; random) {
                      alert("Try Again. Guess to Low. " + guessCount + " tries left.");
                  }
              guessCount--;
  
          }   
      }
  </code></pre>