PDA

View Full Version : "Random" image help


megahertzman
11-22-03, 07:47 PM
Hi. I can't find a certain JavaScript for images.

I have about 365 different images in an image directory, all of the same pixel size. I want the images to appear on my homepage, one at a time, and change automatically one per day. For instance, on the first day of the year, I want the file “images/pic001.gif” to appear on my homepage, and the next day, “images/pic0002.gif” to replace that image, and so on. Basically, a new image for a new day. Any solutions?

alphadesk
11-22-03, 08:08 PM
This one may do what you want.

http://www.raingod.com/raingod/resources/Programming/JavaScript/Software/RandomImages/Source.html

B&T
11-22-03, 08:16 PM
Just try this:

<script type="text/javascript">
nRandom = Math.ceil(Math.random() * 99);
document.write ('<img src="image' + nRandom + '.jpg">');
</script>

This will randomly load image1.jpg through image99.jpg.