Rotating sponsors image script assistance needed...

Discussion in 'JavaScript' started by NewComputer, Mar 19, 2005.

  1. #1
    Here is what I have so far:

    Very rudimentary I know, but here it is:

    var rand_int = Math.floor(Math.random()*4);
    var photos = new Array(4)
    photos[0] = '<img src="images/smittys-logo.gif">';
    photos[1] = '<img src="images/rickys-logo.jpg">';
    photos[2] = '<img src="images/rayssecurity.jpg">';
    photos[3] = '<img src="images/purdys-logo.jpg">';
    document.write(photos[rand_int]);

    This accomplishes most of what I need, EXCEPT I would like to add above the image the actual company name. eg:

    Team sponsored by (then company name inserted from .js here) <br>
    (company logo inserted here by .js)
     
    NewComputer, Mar 19, 2005 IP
  2. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can find some more code on the topic in the thread 11620. In general, you need your own objects. For example:

    function ImageInfo(url, title)
    {
        this.url = url;
        this.title = title;
    }
    Code (markup):
    You will use this object like this:

    images.push(new ImageInfo("/images/img1.jpg", "My Title"));
    Code (markup):
    Finally, you will generate images like this:

    img = document.getElementById("my-img-id");
    img.src = images[index].url;
    Code (markup):
    You can also use document.write for this, but I would rather use DOM instead (the example above).

    J.D.
     
    J.D., Mar 19, 2005 IP
  3. topwebserv

    topwebserv Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    look at phpadsnew dot com << free advertising script easy to use [ free ]
     
    topwebserv, Aug 8, 2006 IP