Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have this page which contains a "main" image and 3 detail shots

 

http://www.florencefashions.com/product.aspx?product=23

 

When a detail shot is clicked then the main image changes to that one, i've just done this simply in the click event of the image control.

 

The client wants it where the page doesnt jump to the top when its clicked, i.e. they want to avoid the postback.

 

Can I do this in Javascript, if so any help appreciated as I have zero experience with JS!

 

Thanks

Posted

Javascript image change

 

Off the top of my head...

 

<script type="text/javascript"><!--
function showimg(url) {
 //imgproduct is the image element in the HTML
 var imgelement = document.getElementById("imgproduct");
 if (imgelement) imgelement.src = "products/" + url;
}
//--></script>

<!-- The thumbnails themselves -->
<img src="products/23a.jpg" onclick="javascript:showimg('23a.jpg')" />
<img src="products/23b.jpg" onclick="javascript:showimg('23b.jpg')" />
<img src="products/23c.jpg" onclick="javascript:showimg('23c.jpg')" />

 

Something like that.

 

Good luck :cool:

Never trouble another for what you can do for yourself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...