Generate Random Numbers

[Total: 0    Average: 0/5]

This example shows you a simple and easy way to generate a random number using javascript.

Head Code:

<script langauge="javascript">
function RandomNumber(maxnumber) {
  var number = Math.round(maxnumber * Math.random());
  alert(number)
}
</script>

Body Code:

<center>
<form>
  <input type="button" value="Generate a Random Number Between 0 and 100"
  onClick="RandomNumber(100)">
</form>
</center>

Times Viewed: 3

Leave a Reply

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