Hi I am making a basic "guess what number I'm thinking of" script and I cant figure out what I'm doing wrong. When I enter my number it changes it to the right number and says correct.
(p.s. kinda new so could be dumb mistake)
heres my script:
<html>
<head>
<script language="Javas cript">
function get_random()
{
var ranNum1= Math.floor(Math .random()*4+1);
return ranNum1;
}
function match_random()
{
var the_answer=get_ random()
if(document.for m1.textbox1.val ue=the_answer)
{
alert("Correct! ")
}
else if
(document.form1 .textbox1.value !=the_answer)
{
alert("Sorry,th e number was "+the_answe r)
}
}
</script>
</head>
<body>
Try to guess what number I'm thinking by typing it in the text box and then clicking the button. (It's between 1 and 5)
<form name="form1">
<input type="text" name="textbox1" >
<input type="button" value="Click me!" onclick="match_ random()"
</body>
</html>