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="Javascript">
function get_random()
{
var ranNum1= Math.floor(Math.random()*4+1);
return ranNum1;
}
function match_random()
{
var the_answer=get_random()
if(document.form1.textbox1.value=the_answer)
{
alert("Correct!")
}
else if
(document.form1.textbox1.value!=the_answer)
{
alert("Sorry,the number was "+the_answer)
}
}
</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>