Javascripts > Misc Javascripts > Game of Chance
Script Title: Game of Chance
Description: Roll the Dice and see if you win.
Example: Available
Copy the following code into your <HEAD></HEAD> tags.<script language="javascript"> // //This Script belongs to Blade: Aaron Connelly //It may be used for nonComercial profit // function rollDice(){ DiceOne=Math.round(Math.random() * 5) + 1 result1=document.random.dice.value=DiceOne DiceTwo=Math.round(Math.random() * 5) + 1 result2=document.random.dice2.value=DiceTwo equal=document.random.dice3.value=result1 + result2 if(document.random.dice3.value=="12"){ alert("you WON!!!!!! with the LUCKY roll of 12 ") } if(document.random.dice3.value=="2"){ alert("you got SNAKE EYES you lose. Sorry.") } if(document.random.dice3.value=="7"){ alert("you WON!!!!! with the LUCKY roll of 7 ") } } </script>
Copy the following code between the <BODY></BODY> tags of your html page.<form name="random"><center> <input type="text" name="dice" size=3>- - - - <input type="text" name="dice2" size=3><BR> Combined roll : For the Win!<BR> <hr width=35><input type="text" name="dice3" size=7><hr width=35><BR> <input type="button" value=" ROLL......" onclick="rollDice()"> </form> <BR><BR><BR> To win you must get either 12 or 7. </center>
Enter your name and email address to have this script sent right to your Inbox for later viewing. First Name Last Name Email