Changing Pictures on a website

Sharky Forums


Results 1 to 7 of 7

Thread: Changing Pictures on a website

  1. #1
    Goldfish ultra_lime's Avatar
    Join Date
    Jun 2002
    Location
    IL
    Posts
    81

    Changing Pictures on a website

    ive been to a website where i can go one minute and see a picture on the top and go there again the next minute and have a diffrent picture and so on. how did they do that? i think what would be nice on my website.
    thanks
    "A"
    Say what? awwww. thanks!
    You are these reason Forums ROCK!!

  2. #2
    Goldfish devalt's Avatar
    Join Date
    Jul 2003
    Location
    Dallas, TX
    Posts
    61
    Is it an ad rotator or just a random image? Also what technology are you wanting to use?

  3. #3
    Goldfish devalt's Avatar
    Join Date
    Jul 2003
    Location
    Dallas, TX
    Posts
    61
    Example of how to do it using javascript:

    Code:
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    var theImages = new Array()
    
    theImages[0] = '1.gif'
    theImages[1] = '2.gif'
    theImages[2] = '3.gif'
    theImages[3] = '4.gif'
    
    var j = 0
    var p = theImages.length;
    var preBuffer = new Array()
    for (i = 0; i < p; i++){
    preBuffer[i] = new Image()
    preBuffer[i].src = theImages[i]
    }
    var whichImage = Math.round(Math.random()*(p-1));
    function showImage(){
    document.write('<img src="'+theImages[whichImage]+'">');
    }
    </script>
    </head>
    <body>
    <SCRIPT LANGUAGE="JavaScript">
    showImage();
    </script>
    </body>
    </html>

  4. #4
    Catfish
    Join Date
    Jan 2001
    Location
    Bexleyheath, Kent, England
    Posts
    169

    it can be done something like this

    <script language="JavaScript" type="text/javascript"><!--
    function makeArray(len)
    {
    for (var i = 0; i < len; i++) this[i] = null;
    this.length = len;
    }
    // This is where the array of imagesis created.
    wwwRand = new makeArray(3);
    wwwRand[0] = "<img src='images/photos/image1.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image1'>";
    wwwRand[1] = "<img src='images/photos/image2.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image2'>";
    wwwRand[2] = "<img src='images/photos/image3.jpg' border='0' width='268' height='132' hspace='0' vspace='0' alt='image3'>";

    // The random number generator.
    function rand(n)
    {
    seed = (0x015a4e35 * seed) % 0x7fffffff;
    return (seed >> 6) % n;
    }
    </script>
    Last edited by Dan@354-Pines; 10-03-2003 at 12:49 PM.

  5. #5
    Expensive Sushi
    Join Date
    Sep 2003
    Location
    Jersey Shore
    Posts
    39

  6. #6
    Yup... i know its kool!!!

    i think the people already sumed it up. I read bout that in my java book over the summer too. You could use it for all sorts of stuff like pics, words, quotes, and anything else you can think im pretty sure. Starcraft Legacy has a quote generator i think sorta like your picture generator!\

    Have fun with your new found knowledge

  7. #7
    Expensive Sushi charroBOB's Avatar
    Join Date
    Jun 2003
    Location
    B612, PuertoRico
    Posts
    18

    Talking java is soooo complicated...

    These Guys have it down to like, 10 lines of PHP..

    cheers!
    Mediocrity is so... uh, rated.

Posting Permissions

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