...

View Full Version : Runtime Error



pj59
09-24-2005, 08:31 AM
When I test my script - I am getting 3 errors

Runtime Error do you want to Debug
Line 14 - Images is undefined

Line 25 - myImage.2.src is null or not an object
Line 27 - myImage.3.src is null or not an object

Here is my script:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Lab 4 - Functions</title>
<script language="javascript" type="text/javascript">
// created by: Pam Davis
// on September 2005

if (document.images) {
// if images are supported by the browser, create an array of images and preload them

var myImage = new Array() // list Images
myImage[0] = new Images()
myImage[0].src = "images/image1.gif"
myImage[1] = new Images()
myImage[1].src = "images/image2.gif"
myImage[2] = new Images()
myImage[2].src = "images/image3.gif"
myImage[3] = new Images()
myImage[3].src = "images/image4.gif"

function changeImg(valueClick) {
if (valueClick == 0) {
document.images[1].src = myImage[2].src
} else if (valueClick == 1) {
document.images[0].src = myImage[3].src
} else {
alert("Houston, we have a problem")
}

return false; //prevent click from going anywhere
}

}
</script>
</head>
<body>
<table width="300" border="0">
<tr>
<td><a href="Lab4.htm" onClick="changeImg(0);return false;"><img src="images/image1.gif" name="img1" width="300" height="150" ></a></td>
<td><a href="Lab4.htm" onClick="changeImg(1);return false;"><img src="images/image2.gif" name="img2" width="300" height="150" ></a></td>
</tr>
</table>
</body>
</html>

I can't seem to figure out what the problem is. I would appreciate if someone could pointed out what I am doing wrong or what the problem may be. Runtime error - Debug is all new to me...I don't know too much about it other than it tell you there is an error in your script.

Thanks for your help on this matter!

PJ

_Aerospace_Eng_
09-24-2005, 09:34 AM
its

new Image()
not new Images()

pj59
09-24-2005, 09:49 AM
Thank you so much!!! I can't believe a little typo error would cause so much problem :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum