I have 5 images set up to fit within the header on my web page. I want each time the pages loads to randomly display 1 of the 5 images in the header… Is this complicated? Anyone got any ideas?
Thanks, Tom
[code=php]<script type="text/javascript"> <!-- image = new Array() image[0] = "pic1.jpg" image[1] = "pic2.jpg" image[2] = "pic3.jpg" image[3] = "pic4.jpg" image[4] = "pic5.jpg" function showImg(){ index = Math.floor(Math.random() * image.length); document.rdm_img.src=image[index] } // add onload="showImg()" to the opening BODY tag //--> </script> <img src="" name="rdm_img"> [/code]
Help @tomyknoker spread the word by sharing this article on Twitter...