[thelist] HELP ASP gurus -- random numbers is hard
Eric Miller
eric at OAKTREE.com
Tue Dec 5 12:29:50 CST 2000
one trick I read in one of the O'Reilly books is to use the Date() object as
a base for your random numbers. specifically, the seconds.
The native javascript math.random functions aren't truly random. so if you
use that in combination with the current minutes and/or seconds as a
multiplier or divisor, you'll get nicely mixed numbers.
I've used it to start an image rotator at a random point:
function rotateImages() {
if(document.images) {
roughNm = new Date(); roughNm = roughNm.getSeconds();
document.rotator.src = "/images/" + imageRotator[eval(Math.floor(roughNm /
10))] + ".gif";
window.setTimeout('rotateImages();', 10000);
}
}
spammy side note--sho wa jo shu, Amanda!
Eric
-----Original Message-----
From: Edd Partee [mailto:edd at vilocity.com]
Sent: Tuesday, December 05, 2000 9:41 AM
To: thelist at lists.evolt.org
Subject: [thelist] HELP ASP gurus -- random numbers is hard
Yeah, so is proper English.
But seriously. All I want to do is put 10 unique random numbers into an
array. I can get the array and I can get 10 numbers, but they're not all
unique enough. I've tried some incredibly complicated nested loops, but
I'm just generating errors with that. Please give a little if you can.
TIA
E. Partee
---------------------------------------
For unsubscribe and other options, including
the Tip Harvester and archive of TheList go to:
http://lists.evolt.org Workers of the Web, evolt !
More information about the thelist
mailing list