Jump to content

swaping images


mediasix

Recommended Posts

Hi,

I want to acheive something that i am unsure how to do.

i want to have a picture of say 400px by 400px with several thumbnails of 50px by 50px underneath.

when you click on each one, it will change the 400px by 400px image, no matter which one you click on.

i have some code but dont think that it is sufficient. (the code is for onmouseover but i want it for onclick

<img src="images/01.jpg" alt="image01" name="image01" id="image01">
<img src="images/02.jpg" alt="image02" name="image02" id="image02" onclick="image01.src='images/image02.jpg'>

please help

thanks in advance

mediasix

Link to comment
https://forums.phpfreaks.com/topic/81668-swaping-images/
Share on other sites

not to worry i answered my own question, here is the code below.

my only question is, how could i make it work with the alt attribute??

cheers

mediasix  :)

<html>
<head>
<script type="text/javascript">
if (document.images) {
image01 = new Image;
image02 = new Image;
image01.src = 'images/01.jpg';
image02.src = 'images/02.jpg';
} else {
image01 = '';
image02 = '';
document.rollimg = '';
}
</script>
</head>
<body>
<p align="center"><img src="images/01.jpg" border="0" alt="Larger version of one of the smaller images below" name="rollimg" /></p>

<p align="center">
<img src="images/01small.jpg" onclick="document.rollimg.src=image01.src;" />
<img src="images/02small.jpg" onclick="document.rollimg.src=image02.src;" />
</p>
</body>

Link to comment
https://forums.phpfreaks.com/topic/81668-swaping-images/#findComment-414920
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.