Javascript Image swap question

Mondeo

Centurion
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
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
 
Javascript image change

Off the top of my head...

Code:
<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:
 
Back
Top