...

View Full Version : "Randomizing" Images



Nick1
01-15-2004, 12:57 AM
Please go here to view an example of what I'm speaking of:

http://www.cavesofnarshe.com

If you refresh the page, the images and game advertisement at the top of the screen should change. It appears then that these images are 'randomized'. How is this accomplished? Can you set the rate at which each image appears?

Thanks to anyone who replies. :)

lavalamp
01-15-2004, 10:50 AM
This isn't JavaScript or any other client-side language doing this. It's a server-side language called PHP. It probably works by generating a random number and then using it to pick a couple of images out of an array to create the header of the page.

Garadon
01-15-2004, 11:35 AM
This is only an example, it selecs between 6 pictures (0.jpg-5.jpg)



<body>
<script>
I=Math.floor(Math.random()*6);
document.write('<img src="'+I+'.jpg";>');
</script>
</body>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum