[Javascript] Random file on page load... or at least that was the idea :(

McCoy, Thomas TMccoy at city.newport-beach.ca.us
Thu Oct 17 13:38:51 CDT 2002


Thanks Harry!  The "random number" was exactly what I was looking for.

Am I correct in saying that the other code was randomly selecting a movie
based on the date and time?  (Sorry to be a bother, but I'm trying to learn
as I go here)
 
 
Sincerely,
Thomas McCoy

-----Original Message-----
Thomas, a quick question for you: are you looking for a random number,
or a number based on the time of day?

If you want a random number (to pick a random file from your array), try
this:

// replace all of this
len = movies.length;
today=new Date();
today=today.getTime()/10;
temp_number=today%len;
rnd = Math.round(temp_number);

// with this one line
rnd = (Math.floor(Math.random() * movies.length));



More information about the Javascript mailing list