»
AnglaisFran�aisVietnamien

Imprimer - Guess 1 - 100 - JavaScriptBank.com

Version compl�te: jsB@nk » Game » Guess 1 - 100
URL: https://www.javascriptbank.com/guess-1-100.html

Guess 1 - 100 © JavaScriptBank.comUn autre JavaScript suppose un certain nombre de jeux. Toutefois, celui-ci a automatiquement un ensemble de 1 - 100.

Version compl�te: jsB@nk » Game » Guess 1 - 100
URL: https://www.javascriptbank.com/guess-1-100.html



JavaScript
<SCRIPT LANGUAGE="JavaScript"><!-- Begin// var js_mult1=3141var js_mult2=5821var js_m1=100000000var js_m2=10000var js_iseed=0var js_iseed1=0var js_iseed2=0function random() {if (js_iseed == 0) {now = new Date()js_iseed = now.getHours() + now.getMinutes() * 60 + now.getSeconds() * 3600}js_iseed1 = js_iseed / js_m2js_iseed2 = js_iseed % js_m2var tmp = (((js_iseed2 * js_mult1 + js_iseed1 * js_mult2) % js_m2) * js_m2 + (js_iseed2 * js_mult2)) % js_m1js_iseed = (tmp + 1) % js_m1return (Math.floor((js_iseed/js_m1) * 100))}var nGuesses = 0function GuessNum() {var responsevar num = parseInt(document.forms[0].guess.value)document.forms[0].guess.value = num nGuesses++response = ""if (num < myNumber)    response = response + "Higher!"if (num > myNumber)    response = response + "Lower!"if (num == myNumber) {respone = "Correct!";alert ("Right!!  Reload the page to start another game....");}document.forms[1].result.value=responsedocument.forms[1].guesses.value=nGuessesdocument.forms[0].guess.focus()document.forms[0].guess.select()return true}function GiveUp() {var responsenGuesses = 0alert("The number was " + myNumber +".  Reload page to start a new game....");}// End --></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<BODY onLoad="document.forms[0].guess.focus();document.forms[0].guess.select()"><SCRIPT>myNumber = random();nGuesses = 0</SCRIPT><FORM onSubmit="GuessNum(); return false">Your Guess: <INPUT TYPE="text" NAME="guess" SIZE=5><INPUT TYPE="button" VALUE=" Guess... " onClick="GuessNum();"><INPUT TYPE="button" VALUE=" GiveUp " onClick="GiveUp();"><br><br>#-Guesses: <INPUT TYPE="text" NAME="guesses" SIZE=3>INFO: <INPUT TYPE="text" NAME="result" SIZE=10></FORM></body><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->