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 6 of 6
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I'm completely stumped, but I'm sure it's an easy problem

    Why am I getting object expected when onload occurs?

    <html>
    <head>
    <script>
    function allButtonsUp();
    {
    var buttonArray = new Array("home","skills","experience","achievements","education","contact");
    for (var i=0; i<buttonArray.length; i++)
    {
    var j = buttonArray[i];
    document.getElementById(j).innerHTML = '<img src="' + j + '_up.jpg">';
    }
    }

    function buttonDown(buttonName)
    {
    document.getElementById(buttonName).innerHTML = '<img src="' + buttonName + '_down.jpg">';
    }

    function buttonUp()
    {
    document.getElementById(buttonName).innerHTML = '<img src="' + buttonName + '_up.jpg">';
    }

    </script>
    </head>
    <body onload="allButtonsUp();">

    <center><img src="banner2.jpg"></center><br>
    <table name="buttontable"><tr>
    <td><div id="home" onmouseover="buttonDown('home');" onmouseout="buttonUp('home');"></div></td>
    <td><div id="skills" onmouseover="buttonDown('skills');" onmouseout="buttonUp('skills');"></div></td>
    <td><div id="experience" onmouseover="buttonDown('experience');" onmouseout="buttonUp('experience');"></div></td>
    <td><div id="achievements" onmouseover="buttonDown('achievements');" onmouseout="buttonUp('achievements');"></div></td>
    <td><div id="education" onmouseover="buttonDown('education');" onmouseout="buttonUp('education');"></div></td>
    <td><div id="contact" onmouseover="buttonDown('contact');" onmouseout="buttonUp('contact');"></div></td>
    </tr></table>

    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,494
    Thanks
    3
    Thanked 499 Times in 486 Posts
    function allButtonsUp(){


    you have allButtonsUp();
    {

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    function allButtonsUp();

    HINT: Turn on script debugging...

    .....Willy

  • #4
    New Coder
    Join Date
    May 2004
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    LOL thanks ROFL

  • #5
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,494
    Thanks
    3
    Thanked 499 Times in 486 Posts
    also this is an alternative to using innerHTML

    (I havent got the right images but you will see the idea)
    Code:
    <html>
    <head>
    <script>
    var ImgPath='http://www.vicsjavascripts.org.uk/StdImages/';
    var buttonArray = new Array("One","Two","Three","Four","Five");
    
    function allButtonsUp(){
     for (var i=0; i<buttonArray.length; i++){
     var j = buttonArray[i];
     obj=document.createElement('IMG');
     obj.src=ImgPath+j+'.gif';
     document.getElementById(j).appendChild(obj);
     obj.width='50';
     obj.height='50';
     }
    }
    
    function button(buttonName,sufix){
    document.getElementById(buttonName).src = ImgPath+buttonName+suffix+'.gif">';
    }
    
    </script>
    </head>
    
    <body onload="allButtonsUp();">
    
    <center><img src="banner2.jpg"></center><br>
    <table name="buttontable"><tr>
    <td><div id="One" onmouseover="button('One','_down');" onmouseout="button('One','_up);"></div></td>
    <td><div id="Two" onmouseover="button('Two','_down');" onmouseout="button('Two','_up);"></div></td>
    <td><div id="Three" onmouseover="button('Three','_down');" onmouseout="button('Three','_up);"></div></td>
    <td><div id="Four"  onmouseover="button('Four','_down');" onmouseout="button('Four','_up);"></div></td>
    <td><div id="Five"  onmouseover="button('Five','_down');" onmouseout="button('Five','_up);"></div></td>
    </tr></table>
    
    </body>
    </html>

  • #6
    New Coder
    Join Date
    May 2004
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is there a problem with using innerHTML?


  •  

    Posting Permissions

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