I have a <td> where the main picture is displayed and on the other td's the thubnails. Now I want to change the main picture with the thubnail picture everything a different picture is clicked.
The main picture is now showing :
<img src="viewImage.php?type=glimage&name=<?php echo $image['im_image']; ?>" border=0 id="main">
now I have tried :
<a href="#" onclick="main.src='viewImage.php?type=glimage&name=<?php echo $image['im_image2']; ?>"><img src="viewImage.php?type=glimage&name=<?php echo $image['im_image2']; ?>" alt="Click to enlarge" style="border:1px solid #000000; width:70; height:53px;">
This does not change the picture in the first td.
What am i doing wrong?
Any help would be appreciated
Image swap
Moderator: General Moderators
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Image swap
I think this is a JS question:
Code: Select all
<!-- MAIN PIC -->
<img src="some-picture.jpg" id="main_pic" />
<!-- A THUMBNAIL -->
<img src="some-other-picture.jpg" style="cursor: pointer;"onclick="document.getElementById('main_pic').src=this.src;" />