SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Javascript random image refresh
-
Oct 20, 2007, 12:21 #1
- 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
-
Oct 21, 2007, 01:15 #2
- 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?
-
Oct 21, 2007, 14:50 #3
- 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
-
Oct 23, 2007, 16:18 #4
- 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]);
-
Oct 24, 2007, 05:25 #5
- 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