Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-01-2011, 11:34 PM   PM User | #1
JSanday
New to the CF scene

 
Join Date: Jun 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
JSanday is an unknown quantity at this point
Question thumbnail image select missing href for lightbox

Hello, I would like some help with a two stage display of thumbnails. I have managed to display all thumbnail product images of my targetId in a scrolling div from the contents of my targetId image folder. I have also managed to display the thumbnail as a larger image in a html image. I would now like to apply a href link to the larger image so that I can display using jsquery lightbox, but I can't figure out what code i need and where it should go. Please help!

Code:
<head>
<script type="text/javascript">
 function replaceImg(path) {
 	var imgDest = document.getElementById('image');
	var imgSrc = path;
	imgDest.setAttribute("src", imgSrc);
	}
</script>

</head>
<body>

    <div class="productimage"><img id="image" img src="product_images/<?php echo $targetID; ?>/<?php echo $targetID; ?>.jpg" width="253" height="378" border="0" /></div>

    <div class="gallerypics"><?php
		$counter = 0; 
     foreach (glob("product_images/$targetID/thumb/*.jpg") as $pathToThumb)
    {
        $filename = basename($pathToThumb);
        echo ('<div class="gallerypicsframe"><a href="javascript:replaceImg(\'product_images/'.$targetID.'/'.$filename.'\')"><img src="'.$pathToThumb.'"" width="60" height="90" border="0"/></a></div>');
        $counter++;
    }
?>

</body>
JSanday is offline   Reply With Quote
Old 06-02-2011, 08:59 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,260
Thanks: 10
Thanked 532 Times in 526 Posts
devnull69 will become famous soon enough
Usually jQuery lightBox takes the following markup
Code:
<div id="container">
   <a href="LARGEIMAGE.jpg"><img src="SMALLIMAGE.jpg"/></a>
   <a href="LARGEIMAGE.jpg"><img src="SMALLIMAGE.jpg"/></a>
   ...
</div>
So if you manage to get your markup into this format, you can have lightBoxes with just
Code:
$('#container a').lightBox();
devnull69 is offline   Reply With Quote
Reply

Bookmarks

Tags
href, image, thumbnail

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:19 AM.


Advertisement
Log in to turn off these ads.