Pauliostro
07-13-2004, 03:25 AM
Hi,
Hoping someone out in web land might know the answer to this. I am setting up a template page for a site.. and basically have got a image swap function happening (code below), it shows a main image with thumb images. (all images are 300px x 200px)
I am wanting to alter it so that if no thumb image is in the directory then it will not display and also not rollover to the large image
Any thoughts anyone?? some sort of if function... im not sure...
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
if(document.images) {
pics = new Array();
pics[1] = new Image();
pics[1].src = "1.jpg";
pics[2] = new Image();
pics[2].src = "2.jpg";
pics[3] = new Image();
pics[3].src = "3.jpg";
pics[4] = new Image();
pics[4].src = "noimage.jpg";
}
function changer(from,to) {
if(document.images) {
document.images[from].src = pics[to].src;
}
}
//-->
</SCRIPT>
</head>
<body>
<table width="320" border="0" cellspacing="12" cellpadding="0">
<tr>
<td colspan="3"><img name="img1" border="0" vspace="0" hspace="0" src="1.jpg" width="300" height="200"></td>
</tr>
<tr>
<td><a onMouseOver="changer('img1',2)" onMouseOut="changer('img1',1)" href="javascript:void"><img src="2.jpg" width="92" height="61" border="0"></a></td>
<td><a onMouseOver="changer('img1',3)" onMouseOut="changer('img1',1)" href="javascript:void"><img src="3.jpg" width="92" height="61" border="0"></a></td>
<td><a onMouseOver="changer('img1',4)" onMouseOut="changer('img1',1)" href="javascript:void"><img src="noimage.jpg" width="92" height="61" border="0"></a></td>
</tr>
</table>
</body>
</html>
Thanks in advance!!
Hoping someone out in web land might know the answer to this. I am setting up a template page for a site.. and basically have got a image swap function happening (code below), it shows a main image with thumb images. (all images are 300px x 200px)
I am wanting to alter it so that if no thumb image is in the directory then it will not display and also not rollover to the large image
Any thoughts anyone?? some sort of if function... im not sure...
<html>
<head>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
<!--
if(document.images) {
pics = new Array();
pics[1] = new Image();
pics[1].src = "1.jpg";
pics[2] = new Image();
pics[2].src = "2.jpg";
pics[3] = new Image();
pics[3].src = "3.jpg";
pics[4] = new Image();
pics[4].src = "noimage.jpg";
}
function changer(from,to) {
if(document.images) {
document.images[from].src = pics[to].src;
}
}
//-->
</SCRIPT>
</head>
<body>
<table width="320" border="0" cellspacing="12" cellpadding="0">
<tr>
<td colspan="3"><img name="img1" border="0" vspace="0" hspace="0" src="1.jpg" width="300" height="200"></td>
</tr>
<tr>
<td><a onMouseOver="changer('img1',2)" onMouseOut="changer('img1',1)" href="javascript:void"><img src="2.jpg" width="92" height="61" border="0"></a></td>
<td><a onMouseOver="changer('img1',3)" onMouseOut="changer('img1',1)" href="javascript:void"><img src="3.jpg" width="92" height="61" border="0"></a></td>
<td><a onMouseOver="changer('img1',4)" onMouseOut="changer('img1',1)" href="javascript:void"><img src="noimage.jpg" width="92" height="61" border="0"></a></td>
</tr>
</table>
</body>
</html>
Thanks in advance!!