Script Categories













Games >>> Dice Roller.

Next time you play a game involving dice, give this JavaScript Dice Roller a try! Just tell it how many dice to use, how many sides are on each die, and it'll give you the total for the number of dice you rolled!

What dice type? How many dice to roll?

3 Sided
4 Sided
5 Sided
6 Sided
8 Sided

10 Sided
12 Sided
20 Sided
30 Sided
100 Sided

1
2
3
4
5

6
7
8
9
10

Add the below code to the <body> section of your page:

<script language="javascript" type="text/javascript">
/* Visit http://www.yaldex.com/ for full source code
and get more free JavaScript, CSS and DHTML scripts! */
<!-- Begin
var die = 6;
var dice = 3;
function dice_roll(die, dice) {
var roll = 0;
for (loop=0; loop < dice; loop++) {
// random number fix by George Johnston (cali_scripter@yahoo.com)
roll = roll + Math.round(Math.random() * die) % die + 1;
}
document.form.text.value = roll;
}
// End -->
</script>
<center>
<form name=form>
<table border=2 cellpadding=5>
<tr>
<td
colspan=2 align=middle>What dice type?</td>
<td
colspan=2 align=middle>How many dice to roll?</td>
</tr>
<tr>
<td
valign=top align=middle>
<br><input type=radio name=sides onclick="die = 3">3 Sided
<br><input type=radio name=sides onclick="die = 4">4 Sided
<br><input type=radio name=sides onclick="die = 5">5 Sided
<br><input type=radio checked name=sides onclick="die = 6">6 Sided
<br><input type=radio name=sides onclick="die = 8">8 Sided
</td>
<td
valign=top align=middle>
<br><input type=radio name=sides onclick="die = 10">10 Sided
<br><input type=radio name=sides onclick="die = 12">12 Sided
<br><input type=radio name=sides onclick="die = 20">20 Sided
<br><input type=radio name=sides onclick="die = 30">30 Sided
<br><input type=radio name=sides onclick="die = 100">100 Sided
</td>
<td
valign=top align=middle>
<br><input type=radio name=number onclick="dice = 1">1
<br><input type=radio name=number onclick="dice = 2">2
<br><input type=radio checked name=number onclick="dice = 3">3
<br><input type=radio name=number onclick="dice = 4">4
<br><input type=radio name=number onclick="dice = 5">5
</td>
<td
valign=top align=middle>
<br><input type=radio name=number onclick="dice = 6">6
<br><input type=radio name=number onclick="dice = 7">7
<br><input type=radio name=number onclick="dice = 8">8
<br><input type=radio name=number onclick="dice = 9">9
<br><input type=radio name=number onclick="dice = 10">10
</td>
</tr>
<tr>
<td
align=middle colspan=4>
<input type=button value="Roll Dice" name=button onclick="dice_roll(die, dice)">
<input
type=text size=10 name=text>
</td>
</tr>
</table>
</form>
</center>

JavaScript Editor Get Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.



Code was highlighted by 1st JavaScript Editor (The Best JavaScript Editor!).




©