kippy33
08272006, 05:23 PM
I run a random number generating service for a RPG message board I go to, and my website generates only numbers from 1100. How could I script this so that the user can get random numbers between 1X?


View Full Version : Random Number Generating kippy33 08272006, 05:23 PM I run a random number generating service for a RPG message board I go to, and my website generates only numbers from 1100. How could I script this so that the user can get random numbers between 1X? Philip M 08272006, 08:08 PM var rand1 = Math.random();// generates a random number 0.999999999999 var rand 2 = rand1 * x; // where x is the range desired, e.g. 250 var rand3= Math.ceil(rand3); // rounds the number up or var rand4 = Math.ceil(Math.random() * x); kippy33 08272006, 11:05 PM How would I set the input box to be X, and set the submit button to generate the numbers? Philip M 08282006, 08:56 AM How would I set the input box to be X, and set the submit button to generate the numbers? Not sure what it is you are trying to achieve. This is the first time that input box and submit button have been mentioned. Do you want to set the random number range, or does the user select it? Please be a little clearer. What is the code you are using now? elfpickle 08282006, 09:02 AM you must be new to this.. use the guy aboves math for random numbers but in the function function makemerandom(numbax){ var rand1 = Math.random();// generates a random number 0.999999999999 var rand2 = rand1 * numbax; // where x is the range desired, e.g. 250 var rand3= Math.ceil(rand3); // rounds the number up document.all['yournumba'].value = rand2; } in your form add <input id="yournumba" type="text" value=""> <input type="button" onclick="makemerandom(document.all['yournumba'].value)> sorry about the stuffup. so you enter the desired range into the input box and there you have it 
 
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum