background color change problem

Discussion in 'JavaScript and AJAX' started by Lief Webster, Jan 6, 2008.

  1. Lief Webster

    Lief Webster New Member

    Joined:
    Oct 16, 2007
    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    0
    This is my first time using JavaScript, and I found a tutorial online to learn off of. Here is the code I have made, meant to make three buttons, each of which change the background color of the window.

    Code:
    <html>
    <head>
    
    <SCRIPT LANGUAGE="JavaScript">
    
    function BgColor (color) {
    document.bgColor=color }
    
    </SCRIPT>
    </head>
    
    <body>
    <form>
    <input type="button" name="redbutton" value="Red" onClick="changecolor ('red')">
    
    <input type="button" name="bluebutton" value="Blue" onClick="changecolor ('blue')">
    
    <input type="button" name="greenbutton" value="Green" onClick="changecolor ('green')">
    </form>
    
    </body>
    </html>
    The problem is, whenever you hit a button, nothing at all happens. Any help, please?
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    Just look at your silly mistake dude, check the name of the defined function and the one you are calling!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice