[Javascript] Random file on page load... or at least that was the idea :(
Harry Love
hlove at u.washington.edu
Thu Oct 17 13:31:50 CDT 2002
---------------------------------------
len = movies.length;
today=new Date();
today=today.getTime()/10;
temp_number=today%len;
rnd = Math.round(temp_number);
--------------------------------------
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));
Regards,
Harry
More information about the Javascript
mailing list