PDA

View Full Version : swap more images with onClick



Lost in Space
10-23-2007, 05:16 PM
Hi, can anybody tell me how to complete this code (taken in part from (DF) all I need now is to have at least 10 images that act as buttons so that when you 'onClick' the image will swap with another image.

I have attached my code so you can see. at the moment, the problem is, the second button when clicked, swaps with the 1st image :(

Hope this makes sense

Any help would be much appreciated


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
<script language="JavaScript" src="CAL_JS.js"></script>

<script type="text/javascript" src="swfobject.js" ></script>

<script type="text/javascript">


function Swap(obj){
obj.src=(Swap.swaped=!Swap.swaped)? 'images/cal_jan_over.gif' : 'images/cal_jan.gif';
}
{
obj.src=(Swap.swaped=!Swap.swaped)? 'images/cal_feb_over.gif' : 'images/feb_jan.gif';
}
</script>
</script>
</head>

<body>

<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="183"><a href="javascript:;"><img src='images/cal_jan.gif' width=183 height="15" onclick="Swap(this);showhide(JAN)" id="image1" ></a></td>
<td width="217">&nbsp;</td>
</tr>
<tr>
<td class = archiveBox id="JAN" style="display:none;">
<span class="articleArchive" >
<a href="#">blar blar blar blar blar</a></br></br>
<br />
<a href="#">blar blar blar blar blar</a><br />
<a href="#">blar blar blar blar blar</a> </span> </td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="183"><a href="javascript:;"><img src='images/cal_feb.gif' width=183 height="15" onclick="Swap(this);showhide(FEB)" id="image2" ></a></td>
<td width="217">&nbsp;</td>
</tr>
<tr>
<td class = archiveBox id="FEB" style="display:none;">
<span class="articleArchive" >
<a href="#">blar blar blar blar blar</a></br></br>
<br />
<a href="#">blar blar blar blar blar</a><br />
<a href="#">blar blar blar blar blar</a> </span> </td>
<td>&nbsp;</td>
</tr>
</table>

</body>

</html>

jscheuer1
10-25-2007, 02:51 PM
You could try:

http://home.comcast.net/~jscheuer1/side/myroll/

Lost in Space
10-30-2007, 01:11 PM
jscheuer1, you're a star. worked a treat. I spent ages trying to find a thread that explained it.

thanks a mill.