showing results for - "unicode dice roll js"
Thomas
25 Nov 2017
1    <script type="text/javascript">
2    function roll(n) {
3        var dice = ['\u2680', '\u2681', '\u2682', '\u2683', '\u2684', '\u2685'];
4        var results = '';
5        for (var i=0; i<n; i++) {
6            results += dice[Math.floor(Math.random()*6)] + ' ';
7        }
8        return results;
9    }
10    
11    function doRoll(countElem, resultElem) {
12        document.getElementById(resultElem).innerHTML = 
13            roll(parseInt(document.getElementById(countElem).value));
14    }
15    </script>
16    
17    Enter number of Dice to roll:<br><input type="text" id="dice-roll-number" />
18    <input type="button" onclick="doRoll('dice-roll-number', 'dice-roll-result')" value="Roll!" />
19    
20    Result: <span style="font-size: 64px; line-height: normal" id="dice-roll-result"></span>
21
queries leading to this page
unicode dice roll jsunicode dice roll js