Quote:
Originally Posted by theFez
first of all, this is a javascript question, not a java question. the only similarity between the two is that the latter is a proper subset of the former in name only.
Basically what you need to do is name your large image, then change your onclick to swap the images. so if you change this:
Code:
<img src='imgs/rail_def.jpg'>
to
Code:
<img src='imgs/rail_def.jpg' name='master'>
Now you have named the master image and can use javascript to alter this image. so your tnail links will change to
Code:
<a href="#" onClick="document.master.src='imgs/rail1.gif';" class="popimage"><img src='imgs/thumbs/rail1.jpg' class='popimage'></a>
|
theFez, I think I'm looking at something similar
I used this page as tutorial and seem to have an understanding but can't get the image to swap
http://www.alistapart.com/articles/imagegallery/
the javascript function in the pages header is this:
Code:
function showPic (whichpic) {
if (document.getElementById) {
document.getElementById('placeholder')»
.src = whichpic.href;
if (whichpic.title) {
document.getElementById('desc')»
.childNodes[0].nodeValue = whichpic.title;
} else {
document.getElementById('desc')»
.childNodes[0].nodeValue = whichpic.childNodes[0].nodeValue;
}
return false;
} else {
return true;
}
}
I don't need the title stuff, but don't know which lines of code to erase
The image placeholder is
Code:
<img id="placeholder" src="imgs/blank.gif" alt="" />
and I tried this as the onclick action for the images in the thumb table:
Code:
<a onClick="return showPic(this)" href="imgs/<?php echo $file;?>"><? echo "<img src='imgs/thumbs/$file' class='popimage'></a>
The table builds fine and the page displays correctly but clicking the thumbs just links to the actual image and doesn't swap it.
If I understand your post, is this the same method? Assigning a name to the swapped image and using the image file name as the variable? Or did I miss the point completely?
The current page that I've been banging on for the last three hours is here:
http://www.arch13.com/galtest3.php
Is what I'm doing wrong obvious to you? Or should I drop this method and try your some more? (I tried it once before posting and got back errors when I changed the imgs/rail1.gif to ?php echo $file;? (with brackets of course)