Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: help with my randomixer


Message #1 by "Jeremy Daniels" <jeremyad2000@y...> on Fri, 9 Aug 2002 01:06:06
Dear fellow scripters
      CAN ANYONE HELP ME!!

when i press the roll button it rolls the dice for me but it wont allow me 
to roll any more it just sticks with the dice pictures.
 can you help solv the problem heres the script.... <html>

<head>

</head>
<script language="JavaScript">
<!--
function getRandom( max ) {

iRandom = Math.round((Math.random() * max + 0.5));
return iRandom;
  
}



   

   
function getdice(){ 
rnd1 = getRandom(6);
rnd2 = getRandom(6);
rnd3 = getRandom(6);
rnd4 = getRandom(6);
rnd5 = getRandom(6);
rnd6 = getRandom(6);

// show the picture. 
document.writeln("<img src='dice/die" + rnd1 + ".gif'>");document.writeln
("<img src='dice/die" + rnd2 + ".gif'>");document.writeln("<img 
src='dice/die" + rnd3 + ".gif'>");document.writeln("<img src='dice/die" + 
rnd4 + ".gif'>");document.writeln("<img src='dice/die" + rnd5 
+ ".gif'>");document.writeln("<img src='dice/die" + rnd6 + ".gif'>");

}
// --></script>
<body>
<body bgcolor="black">

<BR>
<BR>
<BR> 
<br>           
<input type="button" value="roll" onclick="getdice()">
</body>


  Return to Index