wrote:
TIA
Google for javascript random.
This was not written by me, but was posted by Joe Greene some time ago in a different news group.
/*
Try this. I wrote a function to generate a random number: */
function Roll_Die(DSize){
var DRoll=0;
for (I=0;I<DSize;I++){
DRoll+=Math.round(Math.random());
} return DRoll
}
/*
Now Given the use of the above function, create an array of image filenames
*/
var MyImages=new Array();
MyImages[0]="foo.gif";
MyImages[1]="bar.jpg";
MyImages[2]="foo-bar.gif";
/*
Next assuming you are manipulating the first image on your page call this function to randomly change pictures.
*/
function RandomPix(){
var P=Roll_Die(MyImages.length);
document.images[0].src="
http://my.server.com/my/imge/folder/"+MyImages[P];
}
/*
You can call the function in onLoad= to only select at load time, or you can create another function with a setInterval() calling itself to randomly change images periodically. Note: if your going to change images at intervals it’s recommened to create a hidden layer which loads them all, in order to minimize the lage when it changes pictures…. */
—
Mike Russell
www.curvemeister.com
www.geigy.2y.net