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:
<html>
<body>
<script type = "text/javascript">
<!--
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...");
}
}
//-->
</script>
<form>
Colour <input type="text" name="inputform" id="textbox" value="">
<input type="submit" value="Submit" onclick="findColor();">
</form>
</body>
</html>
Thanks, any help appreciated.