Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Help. Page Load Photo Question

Status
Not open for further replies.

Flash12

Technical User
Oct 4, 2006
1
0
0
US
I've got a photo on my website that I would like to have change everytime the page loads. Is it possible to set it up to have 5 or 6 photos that randomly change each time the page loads? Thanks!
 
I use a javascript on my page to accomplish this:

Put this in the HEAD of your site...

<script language="JavaScript" type="text/javascript">

<!-- Hide from old browsers

iArray=new Array(
"images/Pic1.jpg",
"images/Pic2.jpg",
"images/Pic3.jpg",
"images/Pic4.jpg",
"images/Pic5.jpg");
ri=Math.floor(iArray.length*Math.random());
ri='<img src="'+ iArray[ri]+ '" border=0>';

// end hiding -->
</script>

Put this where you want the images to display...

<script language="JavaScript" type="text/javascript">
<!--
document.write(ri);
// -->
</script>

Hope this is helps

DBigger
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top