Random Numbers



The Script


      <html>
      <head>
      <SCRIPT type="text/javascript"> 
      function rand()
          {
             now=new Date()
             num=(now.getSeconds())%5
             alert("Your Random Number Is " + num)
         }
      </script>
      </head>
      <body>
          <h1>Random Numbers</h1>
          <form>  
	<input type="button" value="Display a Random 
	Number between 0 and 4"  onClick="rand()">
         </form>
     </body>
     </html>

     You'll need to change the number after the percent sign to five and add a little text to the alert command, and you're good to go.

Close this window to return to Primer #20