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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "Randomizing" Images

    Please go here to view an example of what I'm speaking of:

    http://www.cavesofnarshe.com

    If you refresh the page, the images and game advertisement at the top of the screen should change. It appears then that these images are 'randomized'. How is this accomplished? Can you set the rate at which each image appears?

    Thanks to anyone who replies.

  • #2
    Regular Coder
    Join Date
    Aug 2003
    Location
    Loughborough University
    Posts
    427
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This isn't JavaScript or any other client-side language doing this. It's a server-side language called PHP. It probably works by generating a random number and then using it to pick a couple of images out of an array to create the header of the page.
    AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
    BFG GeForce 6800 Ultra OC 256Mb
    3 * Kingston 256Mb PC3200 DDR400
    Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is only an example, it selecs between 6 pictures (0.jpg-5.jpg)

    Code:
    <body>
    <script>
    I=Math.floor(Math.random()*6);
    document.write('<img src="'+I+'.jpg";>');
    </script>
    </body>


  •  

    Posting Permissions

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