title: Input text form value from HTML into Javascript function
body: <p>Beginner question, I am currently learning JS and I'm trying to write a function that will take a text input from a simple html form. I can't figure out how to pass the text input into the function. This is what I am currently trying:</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;script type = "text/javascript"&gt;
          &lt;!--
  
          var myColor = document.getElementById("textbox").value;
  
  
          function findColor(){
          switch(myColor){
              case "Blue":
                  document.write("just like the sky!");
              break
  
              case "Red":
                  document.write("Just like wine!");
              break
              default:
                  document.write("Suit yourself then...");
  
              }
          }
  
          //--&gt;
          &lt;/script&gt;
  
          &lt;form&gt;
          Colour &lt;input type="text" name="inputform" id="textbox" value=""&gt;
          &lt;input type="submit" value="Submit" onclick="findColor();"&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks, any help appreciated.</p>