Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Runtime Error

  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Runtime Error

    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
    PJ

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    its
    Code:
    new Image()
    not new Images()
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New Coder
    Join Date
    Sep 2005
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much!!! I can't believe a little typo error would cause so much problem
    PJ


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •