mrkwlkn
02-04-2003, 02:11 PM
I would like the number to be random every time the button is pressed. What is wrong with the following code?
=======================================
<SCRIPT>
var item=new Array(
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9");
function randselect() {
do { i=Math.floor(Math.random()*item.length); }
while(typeof(item[i])=="undefined"); return item[i];
}
</SCRIPT>
<BODY>
<INPUT TYPE="button" value="Select New Random Number" ONCLICK="document.value=randselect();">
<P>
<SCRIPT>document.write(randselect());</SCRIPT>
=======================================
Thanks in advance.
=======================================
<SCRIPT>
var item=new Array(
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9");
function randselect() {
do { i=Math.floor(Math.random()*item.length); }
while(typeof(item[i])=="undefined"); return item[i];
}
</SCRIPT>
<BODY>
<INPUT TYPE="button" value="Select New Random Number" ONCLICK="document.value=randselect();">
<P>
<SCRIPT>document.write(randselect());</SCRIPT>
=======================================
Thanks in advance.