SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Location
    Lawrence, KS
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript random image refresh

    I was wondering if there is a way to use the random image upon refresh, but also apply a rollover to the image and a link?

    I have page in which I have 6 images that I want to change when I user hits refresh or visits again . . . but I also need each image to link to a page and when the user rollover the image I need another image to appear.

    Is this even possible?
    Affordable design solutions!
    www.jberradesign.com

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it would be easier to do this using php or asp, is that an option?

  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Location
    Lawrence, KS
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, that is an option, but I have no idea how to apply it. I did find a PHP script online, but it was only for random refresh, not for refresh plus rollover. Do you have any good resources?
    Affordable design solutions!
    www.jberradesign.com

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd try something like this:

    - create a php array of the html you need to switch
    - randomize the array using shuffle
    - take the first element of the array and display it

    Code:
    $imageArray = array(
      "<a href='image1link.php'><img src='image1.gif' onmouseover='this.src=\'image1_over.gif\';' onmouseout='this.src=\'image1.gif\';'></a>",
      "<a href='image2link.php'><img src='image2.gif' onmouseover='this.src=\'image2_over.gif\';' onmouseout='this.src=\'image2.gif\';'></a>"
    );
    shuffle($imageArray);
    echo ($imageArray[0]);
    Untested and I am not Mr PHP

  5. #5
    SitePoint Member
    Join Date
    Jun 2007
    Location
    Lawrence, KS
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure what you mean by a PHP array of the html . . . I am definitely not Ms. PHP either . . .

    Sorry, I feel like a total ignoramus.
    Affordable design solutions!
    www.jberradesign.com


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
  •