Quote:
Originally Posted by skyhigh007 You meant, use PHP loop to generate the html list and put the onclick() inside the loop? |
Yeah. If you're already using PHP to include header and footer sections, which I think you are based on other threads you've started, you can use PHP to generate the HTML for the gallery and have it put the onClick() events where they need to be, etc. I would imagine you would need an array of some kind to associate the larger images with the thumbnails unless you go with a numbering scheme and file naming convention.
Here is a pseudo-code example:
Code:
$imgNo=1;
$imgMax=20;
for (;imgNo <= imgMax;imgNo++) {
echo "<img src="imgThumb$imgNo.jpg" onClick="swapImg('img$imgNo.jpg','large-img');">\n"
} So, if you had 20 images you wanted in your gallery, you would name them img1.jpg, im2.jog, etc., and the thumbnails would be imgThumb1.jpg and imgThumb2.jpg and so on. As the loop above executed, it would generate this HTML:
<img src="imgThumb1.jpg" onClick="swapImg('img1.jpg','large-img');">
<img src="imgThumb2jpg" onClick="swapImg('img2jpg','large-img');">
<img src="imgThumb3jpg" onClick="swapImg('img3jpg','large-img');">
and so on. Of course, the above code won't work exactly as written above (which is why it's pseudo-code) but it illustrates an implementation of the algorithm I have in mind. I'm sure others here with more PHP experience would be able to produce actual PHP code that could be used.
Peace...