SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    random image generator

    Hi I have found the following script, my problem is I don't know any javascript and I have tried to work it out but can't seem to make this script work for me.
    I would like to create a folder to store all the images relevent to this page in so that I can keep things neat can some one please help me to understand this script.

    <script language="JavaScript">
    <!--
    // ==============================================
    // Copyright 2003 by jsCode.com
    // Source: jsCode.com
    // Author: etLux
    // Free for all; but please leave in the header.
    // ==============================================

    // Set up the image files to be used.
    var theImages = new Array() // do not change this
    // To add more image files, continue with the
    // pattern below, adding to the array. Rememeber
    // to increment the theImages[x] index!

    theImages[0] = '100.jpg'
    theImages[1] = '200.jpg'
    theImages[2] = '300.jpg'
    theImages[3] = '400.jpg'
    theImages[4] = '500.jpg'

    // ======================================
    // do not change anything below this line
    // ======================================

    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>

    <script language="JavaScript">
    <!--
    // ==============================================
    // Copyright 2003 by jsCode.com
    // Source: jsCode.com
    // Author: etLux
    // Free for all; but please leave in the header.
    // ==============================================
    showImage();
    //-->
    </script>

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change this values
    theImages[0] = '100.jpg'
    theImages[1] = '200.jpg'
    theImages[2] = '300.jpg'
    theImages[3] = '400.jpg'
    theImages[4] = '500.jpg'
    100.jpg -----> to your image name
    if you put your images in a folder make it like this 'images/image.gif'
    while images is the folder where you are storing your pics
    ---------------
    Then put this function
    showImage();
    where you want your pics to be viewed


    Finally I know a more better to random view images using php if you like i can help ...

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your help I don't understand php either and as this is a community website and therefore has no funding other than peoples time I have no money to pay for help.
    But I thank you for your assistance so far.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    karmaman never mind i just like to help for free
    if you need anything about rotating images tell me i will be happy to help i get helped alot of times here so i will be very happy to offer what i know ...
    and by the way i am not a real php programmer or even any other languages ...
    just have a common expertise

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very kind of you free dragon I will try to explain what I want.
    As mentioned this is a community site, so in the section for local history I want to display a series of images about 200px square so that every time the page is refreshed the image will change. It is also important that I can store all the images to do with this section in a folder called LOCAL HISTORY or something similar so that I can reuse the script on different pages by renaming the folder and storeing different images within it.
    I hope that makes some sort of sence.


Bookmarks

Posting Permissions

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