<scriptlanguage="javascript"type="text/javascript"> /* Visit http://www.yaldex.com/
for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin var
my_no,count; functionload() { window.defaultStatus="JavaScript
Guess-a-Number Game"; document.game.help.value="Please
set range of numbers and press the Start button."; document.game.from.focus();
} function
rnd(scale) { var
dd=newDate(); return((Math.round(Math.abs(Math.sin(dd.getTime()))*8.71*scale)%scale));
} function
range() { var
to=1+1*document.game.to.value; count=0; my_no=rnd(to); while(my_no<document.game.from.value) { my_no=rnd(to);
} document.game.help.value="Please
guess a number, enter it, and press Guess.";
} function
guess() { var
no=document.game.number.value; count++; if(no<my_no)document.game.help.value="My
number is greater than "+no+"."; elseif(no>my_no)document.game.help.value="My
number is less than "+no+"."; elsealert("It
takes you "+count+"
attempts to guess this number");
} window.onload=load; // End --> </script> <FORMname=game> <TABLEborder=3>
<TR>
<TD
align=centercolspan=2>Range
of numbers</TD>
<TD
align=centerrowspan=2><inputtype=buttonvalue="
Start "onclick="range()"></TD>
</TR>
<TR>
<TD
align=center>From:<br><inputtype=textname=fromsize=10></TD>
<TD
align=center>To:<br><inputtype=textname=tosize=10></TD>
</TD>
<TR>
<TD></TD>
</TR>
<TR>
<TD
align=centercolspan=3><inputtype=textname=helpsize=70></TD>
</TR>
<TR>
<TD></TD>
</TR>
<tr><tdalign=rightcolspan=3><inputtype=textname=numbersize=10><inputtype=buttonvalue="
Guess "onclick="guess()"></TD>
</TR>
</TABLE> </FORM>