I have a website which dynamically gets images and then displays it but i have sub image which has to update the main image, but this main image is a lightbox which uses href link so i am wondering if someone can show me how to update this href using javascript or something but not reload the page.

I would be greatfull,
Thanks in advance!

Thanks,
Marais

Recommended Answers

All 8 Replies

If you post an example of your code i may be able to help.

If you post an example of your code i may be able to help.

Thanks for the quick reply... And here is my code.

<div class="productImage">
				<?php
				if (!empty($product['filename']) && is_file(_UPLOAD_DIR_.'thumbs/'.$product['filename'])) {
					?>
					<div id="currentImage">
                    <?php if ($SETTINGS_DB['show_zoom'] == 0) {?>
						<img alt="Product <?php echo $product['products_id'];?>" src="<?php echo _UPLOAD_URL_.'productinfo/'.$product['filename'];?>" id="imagePreview" onload="vZoom.add(this, '<?php echo _UPLOAD_URL_.'resized/'.$product['filename'];?>');" />
                        <?php } else { ?>
                        <a href="<?php echo _UPLOAD_URL_.'original/'.$product['filename'];?>" rel="openlightbox" id="link" title="<?php echo readFromDB($product['product_title']);?>"><img alt="Product <?php echo $product['products_id'];?>" src="<?php echo _UPLOAD_URL_.'productinfo/'.$product['filename'];?>"/></a>
                        <?php } ?>
					</div>
					<?php
				}
				
				if ($productImages and count($productImages) > 1) {
					
					echo '<div class="productImages">';
					foreach ($productImages as $image) {
						$onClick = '';
						
						if (is_file(_UPLOAD_DIR_.'thumbs/'.$image['filename'])) {
								$onClick = "replaceImage('"._UPLOAD_URL_.'productinfo/'.$image['filename']."', '"._UPLOAD_URL_.'resized/'.$image['filename']."', 'currentImage');";
						}
						?>
						<img alt="<?php echo $product['product_title'].' '.$image['pi_id'];?>" src="<?php echo _UPLOAD_URL_.'thumbs/'.$image['filename'];?>" title="<?php echo $image['filename'];?>" onclick="<?php echo $onClick; ?>" />
						<?php
					}
					echo '</div>';
				} ?>
			</div>

There is the code.. Note i got it to work with the zoom because it uses javascript, but lightbox uses href.

Do you have the lightbox code linked in the head tags?

Are you saying the lighbox isnt working?

which piece of code specifically needs to work right? or is it all?

I can try and help but im not an expert coder and im doing this while i wait for a response for me on another post.

Cheers
John

Kewl, i have the lightbox linked in the header tags... But i need to update the href link which linkes to the lightbox but i dont know how to do this with javascript...

Im not sure what you are trying to achieve, if its a php thing then maybe you could explain the page or proivide a screen grab and i would see if i can help. But if its javascript then maybe its worth posting over in the javascript section or putting it on stack overflow - just google it

Member Avatar for diafol

THis may be better off in the JS forum. You seems to have a few on.. attributes here. You may wish to place them in event handlers in a script. Just a thought.

THis may be better off in the JS forum. You seems to have a few on.. attributes here. You may wish to place them in event handlers in a script. Just a thought.

Thanks,
I have posted it in the JS Forum, but i still have no answer!!

Thanks,
Marais

Perhaps shouting that you need something ASAP with multiple exclamation points puts off some who might answer.

Something to consider.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.