-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdice.html
More file actions
22 lines (22 loc) · 1.02 KB
/
dice.html
File metadata and controls
22 lines (22 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<html>
<body>
<h1>Perfectly Normal Dice</h1>
<label for="die">Sides:</label>
<input id="die" type="range" min="2" max="100" oninput="DR()" value="6"> <output id="dieNum">6</output>
<button onclick="randf()">roll</button>
<p>Your number is: </p><p id="num">NaN</p>
<output id="normal"></output>
<script>
function randf() {
var die = document.getElementById("die").value
var norm = document.getElementById("normal")
document.getElementById("num").textContent = ((Math.random() * (die - 1)) + 1).toString()
norm.textContent = "Which is of course a perfectly normal number for a d" + die.toString() + " to roll."
}
function DR() {
document.getElementById("dieNum").textContent = document.getElementById("die").value
}
</script>
</body>
</html>