<html> <!-- lucky.html Dave Reed --> <!-- This page displays a lucky number at the click of a button. --> <!----------------------------------------------------------------->
<head> <title> Dave's Lucky Number </title> <script type="text/javascript" src="http://www.prenhall.com/reed/random.js"> </script> <script type="text/javascript"> function DisplayNumber() // Results: displays random number in an alert window { var luckyNum; luckyNum = RandomInt(1, 100);
alert("Your lucky number is: " + luckyNum); } </script> </head>
<body> <div style="text-align:center"> <h2>Lucky Dave's Gift To You</h2> <p>Numbers rule our lives. If you would like the benefit of Lucky Dave's amazing powers of prognostication, click on the button below to receive your guaranteed lucky number for the day!</p> <form name="LuckyForm"> <input type="button" value="Click Here for Lucky Number" onClick="DisplayNumber();" /> </form> </div> </body> </html>
<html> <!-- lucky1.html Dave Reed --> <!-- This page displays a lucky number in a text box. --> <!------------------------------------------------------>
<head> <title> Fun with Forms </title> <script type="text/javascript" src="http://www.prenhall.com/reed/random.js"> </script> <script type="text/javascript"> function DisplayNumber() // Assumes: document.LuckyForm.number exists in the page // Results: displays random number in the text box { var luckyNum; luckyNum = RandomInt(1, 100);
document.LuckyForm.number.value = luckyNum; } </script> </head>
<body> <div style="text-align:center"> <h2>Lucky Dave's Gift To You</h2> <p>Numbers rule our lives. If you would like the benefit of Lucky Dave's amazing powers of prognostication, click on the button below to receive your guaranteed lucky number for the day!</p> <form name="LuckyForm"> <input type="button" value="Click Here for Lucky Number" onClick="DisplayNumber();" /> <br /><br /> <hr /><br /> Your lucky number is: <input type="text" name="number" size=4 value="" /> </form> </div> </body> </html>
|