Forum Moderators: open

Message Too Old, No Replies

Random pictures

         

tamel

11:06 am on Jul 18, 2003 (gmt 0)

10+ Year Member



Hi , i want to know if there is a way if i can have pictures taken in random from a database of images and have them shown in a specific area of a web page every time the page is loaded. Anyone has any ideas? Thx

dmorison

11:11 am on Jul 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Should be straight forward with a bit of server side scripting.

What facilities are available to you on your server?

PHP/ASP/Perl etc.?

Without server side scripting you could show a random image using a directory of images and some JavaScript. This script (untested) should pick a random image from 10 stored in the directory /images/ with filenames image1.jpg through image10.jpg.


<script type='text/javascript'>

number = Math.ceil(rnd()*10);

image = "/images/image" + number + ".jpg";

document.write("<img src='" + image + "'>");

</script>

<noscript>

<img src='/images/image1.jpg'>

</noscript>

tamel

11:24 am on Jul 18, 2003 (gmt 0)

10+ Year Member



Thx!