Link to home
Start Free TrialLog in
Avatar of IDEASDesign
IDEASDesign

asked on

Changing IMG SRC onclick (need to extend functionality)

http://208.106.137.37/gallery.php?cat=9&ID=94

If you take a look at this example (See link above) -- I already have some functionality in place to change out the IMG SRC attribute of the large image when you click on the smaller thumbnail images.  

I need to somehow take this one step further.  More specifically, ... I also need to change out the IMG SRC attributes of the thumbnail images that are clicked.

In my application, a product can have up to 3 images associated with it -- the main image (the large one that's displayed by default) .. and up to 2 additional images (initially represented by thumbnail images).  

A small thumbnail image is created for each of these product images that are uploaded (including the main one) .. and I recently realized that there is currently no way to display the default image again after one of the thumbnail images has been clicked, .. unless the page is refreshed.  

What I'd like to have happen is ... when you click on one of the thumbnail images, .. the IMG SRC attribute of the thumbnail image that was just clicked would be changed to the thumbnail image representing whichever of the large product images was just previously displayed on the left -- in addition to changing out the IMG SRC attribute of the large image (this is how it's currently functioning).

Here's a more visual description of what we'd like to achieve
(upper case = large image & lower case = thumbnail image):

IMAGE1 .. image2   image3

click on image2 = IMAGE2 .. image1   image3

click on image3 = IMAGE3 .. image1   image2

click on image1 = IMAGE1 .. image3   image2


So basically, .. if there are a total of 3 image associated with a product, each of those 3 product images should always be visable/clickable on the page, .. as either a large image or a thumbnail image.

How might I accomplish this using javascript?  Is it even possible?

Thanks in advance,
- Yvan
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of IDEASDesign
IDEASDesign

ASKER

Ahh .. awesome!  Thanks so much!  That works great!

- Yvan