View Full Version : need help with this java script!!

07-26-2002, 04:39 AM
ok i need to develpe a javascript that generates a randome number, then asks you to guess a number, that also gives you hints. ex to high or too low.

any help is greatly appreciated ;)

07-26-2002, 06:08 AM
that sounds suspiciously like a homework assignment

07-26-2002, 06:12 AM
range = 100;
num = Math.round(Math.random()*range);
function guess(g) {
document.guessform.lastguess.value = g;
document.guessform.guesses.value = parseInt(document.guessform.guesses.value)+1;
if (g>num) {
document.guessform.hint.value = "Lower";
}else if (g<num) {
document.guessform.hint.value = "Higher";
document.guessform.hint.value = "Correct";

<form name="guessform" onSubmit="guess(this.myguess.value); return false;">
Guess: <input type="text" name="myguess"><br>
Hint: <input type="text" name="hint"><br>
Last Guess: <input type="text" name="lastguess"><br>
Guesses: <input type="text" name="guesses" value="0"><br>
<input type="submit" value="Guess">