Javascripts > Misc Javascripts > Guess The Number
Script Title: Guess The Number
Description: Guess the Number Game from 1-5.
Example: Available
Copy the following code into your <HEAD></HEAD> tags.<SCRIPT type="text/javascript"> function rand() {now=new Date() num=(now.getSeconds())%5 num=num+1 } function guessnum() {guess=prompt("Your guess?") if (eval(guess) == num) {alert("YOU GUESSED IT!!") rand() } else alert("No. Try again.") } </SCRIPT>
Copy the following code INTO your <BODY> tag.<BODY onLoad="rand()">
Copy the following code between the <BODY></BODY> tags of your html page.<h2>I'm thinking of a number from 1 to 5</h1> <FORM NAME="myform"> <INPUT TYPE="button" VALUE="Guess" NAME="b1" onClick="guessnum()"> </FORM>
Enter your name and email address to have this script sent right to your Inbox for later viewing. First Name Last Name Email