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

Thread: random picture

  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    139
    Thanks
    8
    Thanked 0 Times in 0 Posts

    random picture

    I am using the following to display a random picture on a particular page:

    <SCRIPT TYPE="text/javascript">
    var ccPics = new Array()

    ccPics[1] = "<img src=\"index01.jpg\" width=435 height=500 alt=\"random picture\" border=0>"

    ccPics[2] = "<img src=\"index02.jpg\" width=412 height=500 alt=\"random picture\" border=0>"

    var cc = Math.floor(Math.random() * ccPics.length)
    if (cc == 0) {
    cc = 1
    }
    document.write(ccPics[cc])
    </SCRIPT>

    (I have shortened the example to two pictures ... obviously I can use as many pictures as I want.)

    I wonder if there is a way to assign a lighter weight to some pictures, to have them display less frequently, or a heavier weight to other pictures to have them display more frequently. Or whatever fix / workaround is necessary.

    Thanks!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts


  •  

    Posting Permissions

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