Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    459
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Random Headers on a HTML Page

    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

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    PHP Code:
    <script type="text/javascript">
    var 
    pics=['pic1.jpg','pic2.jpg','pic3.jpg','pic4.jpg','pic5.jpg'];
    onload = function(){
    var 
    myPicdocument.getElementById('mypic');
    myPic.src=pics[Math.floor(Math.random()*pics.length)]
    }
    </script>
    ......
    .......
    <img id="mypic" src=""> 
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •