pj59
09-22-2005, 05:38 AM
I am trying to figure how to change image1 to image4 and image2 to image3 by clicking on the images. Here is what I got so far...I know I am missing something but not sure what. I would also like to have an example how to write onMouseOver and onMouseOut in this program. I have viewed some examples but I am still confused. :confused: When I test this...I am getting error in Line 42 and 43. I would appreciate your help on this matter. This is what I got so far:
myImage[1] = new Image ( )
myImage[1].src = "images/image2.gif"
myImage[2] = new Image ( )
myImage[2].src = "images/image3.gif"
myImage[3] = new Image ( )
myImage[3] = "images/image4.gif"
}
function changeImg( ) {
if value == 0
change image1 document.images[1].src = myImages[2]
{else}
if value == 1
change image 0 document.images[0].src = myImages[3]
{else}
alert("Houston, we have a problem")
return false // prevent click from going anywhere
// -->
</script>
</head>
<body>
<table border=0>
<tr>
<td><a href="Lab4.html"><img src="images/image1.gif" name="image1" width="300" height="150" onClick="changeImg( ); " ></a></td>
<td><a href="Lab4.html"><img src="images/image2.gif" name="image2" width="300" height="150" onClick="changeImg( ); " ></a></td>
</tr>
</table>
</body>
</html>
myImage[1] = new Image ( )
myImage[1].src = "images/image2.gif"
myImage[2] = new Image ( )
myImage[2].src = "images/image3.gif"
myImage[3] = new Image ( )
myImage[3] = "images/image4.gif"
}
function changeImg( ) {
if value == 0
change image1 document.images[1].src = myImages[2]
{else}
if value == 1
change image 0 document.images[0].src = myImages[3]
{else}
alert("Houston, we have a problem")
return false // prevent click from going anywhere
// -->
</script>
</head>
<body>
<table border=0>
<tr>
<td><a href="Lab4.html"><img src="images/image1.gif" name="image1" width="300" height="150" onClick="changeImg( ); " ></a></td>
<td><a href="Lab4.html"><img src="images/image2.gif" name="image2" width="300" height="150" onClick="changeImg( ); " ></a></td>
</tr>
</table>
</body>
</html>