SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Newbie Question

  1. #1
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    323
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)

    Newbie Question

    Hey guys,
    I'm very new to JavaScript programming and so I wrote this function today to try and change the image with a simple click of a button. Code:

    Code:
    <html>
    <head>
    <title>Testing Javascript</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function changeimage() {
    	var img = document.getElementById("Myimage");
        img.src="newimage.png";	
    }
    // -->
    </script>
    </head>
    <body>
    <img src="myimage.png" name="Myimage" ID="Myimage">
    
    <form name="changeimage">
    <input type="button" value="Change Image" onClick="changeimage();">
    </form>
    </body>
    </html>
    But for some reason this does nothing :X Could someone explain what is wrong :X? Thanks!

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    changeimage is ambiguous because it refers to the form as well as the function you're trying to call. Rename one of them.

  3. #3
    SitePoint Addict bronze trophy
    Join Date
    Sep 2005
    Posts
    323
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Works Thanks a lot!


Bookmarks

Posting Permissions

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