Roll A Die

[Total: 0    Average: 0/5]

Roll a die. This shows how to use math to roll a die.

Body Code:

<form name=exf1>
<input type=text name=showdie value="roll the die">
</form>
<a href="javascript:dieIs()">roll the die</a>
<script>
var diceSides= new Array("One","Two","Three","Four","Five","Six");
function dieIs() {
  document.exf1.showdie.value=diceSides[parseInt(Math.random()*diceSides.length)];
}
</script>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *