Generate Random Number in Form Textbox

[Total: 0    Average: 0/5]

This example shows how to get a random number into a form text box.

Body Code:

<form name=exf1>
<input type=text name=r1 value="?">
var MAX_RANDOM = 1000;
function getR()
  MAX_RANDOM = document.exf1.r1.value=parseInt(Math.random()*MAX_RANDOM);
<a href="javascript:getR()">Click to generate new random number</a>
Note: This code will use the new random number as the max random number to generate.

Times Viewed: 0

Leave a Reply

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