Forum Moderators: open

Message Too Old, No Replies

Dynamic home page image

using variables

         

mcjohnson

1:35 pm on Apr 28, 2005 (gmt 0)

10+ Year Member



Friends,

apparently the search function of the site is no longer available, so, while this has probably been asked and answered half a dozen times...

Can you let me know the best method of swapping a main image on the index page? My intent is simply to have one of three or four images be called when a user visits the page. If he/she refreshes the page, a new picture is there. There's no mouseover issues, just a new picture each time someone visits.

Many thanks if you can point me in the right direction.

Best Regards,

Pat

uwebe

6:20 pm on Apr 29, 2005 (gmt 0)

10+ Year Member



Hi

If you have a chance to do it in server script do it like:

<img src="default_image_name<%get_random(5)%>.jpg">

where get_random_image is a server side function getting a random number from 0-5 attaching it to a default_image_nameX.jpg, where images reside on the server.

Other solution is pure javascript solution

document.write("<img src='default_image_name" + get_random(5) + "'>")

where the function is writen in javascript, it is also ran on the client side, so you do not need a server to interpret the code and it could be native html page.

Helpful?

Uwebe

mcjohnson

12:01 pm on May 2, 2005 (gmt 0)

10+ Year Member



I'll give it a shot. Thanks!