-
Notifications
You must be signed in to change notification settings - Fork 0
/
rolldice.js
37 lines (30 loc) · 1.02 KB
/
rolldice.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var result = null;
function rollD4() {
result = Math.floor( Math.random() * 4 ) + 1;
document.getElementById('txtD4').innerHTML = result;
}
function rollD6() {
result = Math.floor( Math.random() * 6 ) + 1;
document.getElementById('txtD6').innerHTML = result;
}
function rollD8() {
result = Math.floor( Math.random() * 8 ) + 1;
document.getElementById('txtD8').innerHTML = result;
}
function rollD10() {
result = Math.floor( Math.random() * 10 ) + 1;
document.getElementById('txtD10').innerHTML = result;
}
function rollD12() {
result = Math.floor( Math.random() * 12 ) + 1;
document.getElementById('txtD12').innerHTML = result;
}
function rollD20() {
result = Math.floor( Math.random() * 20 ) + 1;
document.getElementById('txtD20').innerHTML = result;
}
function rollCustom() {
var custom = document.getElementById("cdicenum").value;
result = Math.floor( Math.random() * custom ) + 1;
document.getElementById('txtCustom').innerHTML = result;
}