Anyone know of a Random Number Picker ?
I have a list of numbers.. and I want a program to randomly pick
numbers from it..
The list is as:
4546546
1516154
8834819
9853487
A bit of Javascript can do that. Copy and paste this into a text editor:
<html>
<head><title>Random Number Picker</title>
<script type="text/javascript">
nums=[4546546,1516154,8834819,9853487];
function getRand(n){
return Math.floor(Math.random()*n);
}
function pickNum(){
out1.value=nums[getRand(nums.length)];
}
function shuffle(){
var tmp;
var tmp2;
for(var i=0;i<5;i++){
for(var j=0;j<nums.length;j++){
tmp=nums[j];
tmp2=getRand(nums.length);
nums[j]=nums[tmp2];
nums[tmp2]=tmp;
}
}
out2.value=nums.join('\n');
}
function setUp(){
out1=document.forms['f1'].elements['t1'];
out2=document.forms['f2'].elements['t2'];
}
onload=setUp;
</script>
</head>
<body>
<form name="f1">
<input name="t1" type="text" />
<input type="button" value="Pick a Number" onclick="pickNum()" />
</form><br />
<form name="f2">
<textarea name="t2" rows="10"></textarea>
<input type="button" value="Shuffle Numbers" onclick="shuffle()" />
</form>
</body>
</html>
Save it with a name dot html (example - randompicker.html). Open the
saved file with your browser and click the buttons.
At the top of the script there's an array called nums. Replace the
numbers between the square brackets with the numbers you want to work
with, separated by commas (example - nums=[3,5,623,17,99,7645])