SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: Help!!!!!

  1. #1
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Help!!!!!

    Hey,

    I keep getting this error -
    Line: 71
    Object doesn't support this property or method
    Here is the code (line 71 commented) -
    PHP Code:
    function showMenu(menu)
    {
        
    menuselect menu;
        
    width parseInt(menu.style.width);
        
    left parseInt(menu.style.left); // <- line 71
        
    menupane document.getElementById('menupane');
        
    menupane.innerHTML document.getElementById('hiddentable').innerHTML;
        
    menudiv document.getElementById('menudiv');
        
    menudiv.style.left parseInt(left);
        
    menudiv.style.width parseInt(width);
        
        if ( 
    parseInt(menudiv.style.height) < '120px' )
        {
            
    menudiv.style.height parseInt(menudiv.style.height) + '20px';
            
    setTimeout("showMenu(menuselect)"50);
        }

    I think it could be that a table cell doesn't have a left CSS property but if that's so, then how can I line the DIV up directly below the <TD> ??? I just checked the MSDN library and it doesn't list left but it does have clientLeft so I tried that but got the same error

    Please help

    Thanks

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) What kind of object is 'menu'?
    2) Why are you assigning it to 'menuselect?
    3) Not sure if its required, but you should probably declare you variables 'var width='
    4) Your if statement is comparing a string and a number. I know JavaScript handles that but the result could be interesting.
    5) Same for when you come to set the height, you are adding a string to an int. I think that will give you a concatenated string, not the number string you want.

    Its possible that #3 will solve your object problem.

    Otherwise hopefully these points sould help clarify the problem.
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Lol, I didn't give enough info

    'menu' is a table cell (<TD>). I'm assigning it to 'menuselect' because I need to use it in the setTimeout() inside the if statement and for some reason, I couldn't get 'menu' to work. I tried number 3 with no success and I removed all the parseInt()'s as I wasn't really sure what they did anyway I just saw someone else use them in this manner

    Here is more code to see if you can find my problem
    PHP Code:
    // function
    function showMenu(menu)
    {
        var 
    menuselect menu;
        var 
    width menu.style.width;
        var 
    left menu.style.left
        menupane 
    document.getElementById('menupane');
        
    menupane.innerHTML document.getElementById('hiddentable').innerHTML;
        
    menudiv document.getElementById('menudiv');
        
    menudiv.style.left left;
        
    menudiv.style.width width;
        
        if ( 
    menudiv.style.height '120px' )
        {
            
    menudiv.style.height menudiv.style.height '20px';
            
    setTimeout("showMenu(menuselect)"50);
        }
    }

    // table
    <table width='100%' align='center'>
                <
    tr>
                    <
    td id='menuselect1' class='menuselect' onMouseOver="this.className = 'menuselectover'; showMenu(this)" onMouseOut="this.className = 'menuselect'">Home</td>
                    <
    td id='menuselect2' class='menuselect' onMouseOver="this.className = 'menuselectover'" onMouseOut="this.className = 'menuselect'">Products</td>
                    <
    td id='menuselect3' class='menuselect' onMouseOver="this.className = 'menuselectover'" onMouseOut="this.className = 'menuselect'">Showcase</td>
                    <
    td id='menuselect4' class='menuselect' onMouseOver="this.className = 'menuselectover'" onMouseOut="this.className = 'menuselect'">Apply for <i>webCP Free</i></td>
                    <
    td id='menuselect5' class='menuselect' onMouseOver="this.className = 'menuselectover'" onMouseOut="this.className = 'menuselect'">Contact</td>
                </
    tr>
                <
    tr>
                    <
    td id='menupane' colspan='5'></td>
                </
    tr>
            </
    table
    Thanks

  4. #4
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should work:
    Code:
    var menuselect; // note global
    
    function showMenu(menu)
    {
        menuselect = menu;
        var width = menu.style.width;
        var left = menu.style.left;
        var menupane = document.getElementById('menupane');
        menupane.innerHTML = (document.getElementById('hiddentable')).innerHTML;
        var menudiv = document.getElementById('menudiv');
        menudiv.style.left = left;
        menudiv.style.width = width;
        
        if ( menudiv.style.height < '120px' )
        {
            menudiv.style.height = menudiv.style.height + '20px';
            setTimeout("showMenu(menuselect)", 50);
        }
    }
    Last edited by dale_burrell; Jan 20, 2003 at 16:22.
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Thanks but still no luck I had a play and I'm not sure what I did but now I have the error changed

    Line: 121
    Object Expected
    and Line 121 is the line where showMenu is called in the table. Here is the JavaScript now -
    PHP Code:
    var menuselect;

    function 
    showMenu(menu)
    {
        
    menuselect menu;
        
    width menu.style.width;
        
    left menu.style.left
        menupane 
    document.getElementById('menupane');
        
    menupane.innerHTML document.getElementById('hiddentable').innerHTML;
        
    menudiv document.getElementById('menudiv');
        
    menudiv.style.left left;
        
    menudiv.style.width width;
        */
        if ( 
    menudiv.style.height '120px' )
        {
            
    menudiv.style.height menudiv.style.height '20px';
            
    setTimeout("showMenu(menuselect)"50);
        }

    Thanks for your help so far

  6. #6
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You keep changing the code. You've removed all the 'var' statements. They are very important!

    You also have to make sure that all your id's are declared correctly - else the object won't exist.

    Best thing would be to post all the code next time.
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  7. #7
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    <script type='text/javascript'>
    var 
    menuselect;

    function 
    showMenu(menu)
    {
        
    menuselect menu;
        
    width menu.style.width;
        
    left menu.style.left
        menupane 
    document.getElementById('menupane');
        
    menupane.innerHTML document.getElementById('hiddentable').innerHTML;
        
    menudiv document.getElementById('menudiv');
        
    menudiv.style.left left;
        
    menudiv.style.width width;
        */
        if ( 
    menudiv.style.height '120px' )
        {
            
    menudiv.style.height menudiv.style.height '20px';
            
    setTimeout("showMenu(menuselect)"50);
        }
    }    
    </script>
    </head>

    <body>
    <table class='bodyline'>
        <tr>
            <td id='hiddentable' style='width: 0px; height: 0px; visibility: hidden'>
            <div id='menudiv' style='position: absolute; z-index: 1; text-align: center;'>
            <table align='center' cellspacing='0' cellpadding='0'>
                <tr>
                    <td width='20px'><img src='images/top-left-corner.gif' /></td>
                    <td bgcolor='#3399FF' align='center'></td>
                    <td width='20px'><img src='images/top-right-corner.gif' /></td>
                </tr>
                <tr>
                    <td bgcolor='#3399FF' align='center' colspan='3'></td>
                </tr>
                <tr>
                    <td width='20px'><img src='images/bottom-left-corner.gif' /></td>
                    <td bgcolor='#3399FF' align='center'></td>
                    <td width='20px'><img src='images/bottom-right-corner.gif' /></td>
                </tr>
            </table>
            </div>
            </td>
        </tr>
        <tr>
            <td align='center' class='header'><img src='images/gaming-header.gif' /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td align='center' valign='top'>
            <table width='100%' align='center'>
                <tr>
                    <td id='menuselect1' class='menuselect' onMouseOver="this.className = 'menuselectover'; showMenu(this)" onMouseOut="this.className = 'menuselect'">Home</td>
                    <td id='menuselect2' class='menuselect' onMouseOver="this.className = 'menuselectover'" onMouseOut="this.className = 'menuselect'">Products</td>
                    <td id='menuselect3' class='menuselect' onMouseOver="this.className = 'menuselectover'" onMouseOut="this.className = 'menuselect'">Showcase</td>
                    <td id='menuselect4' class='menuselect' onMouseOver="this.className = 'menuselectover'" onMouseOut="this.className = 'menuselect'">Apply for <i>webCP Free</i></td>
                    <td id='menuselect5' class='menuselect' onMouseOver="this.className = 'menuselectover'" onMouseOut="this.className = 'menuselect'">Contact</td>
                </tr>
                <tr>
                    <td id='menupane' colspan='5'></td>
                </tr>
            </table>
            </td>
        </tr>
    </table> 

  8. #8
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This works for me.
    Code:
    <script type='text/javascript'>
    var menuselect;
    
    function showMenu(menu)
    {
        menuselect = menu;
        var width = menu.style.width;
        var left = menu.style.left
        var menupane = document.getElementById('menupane');
        menupane.innerHTML = (document.getElementById('hiddentable')).innerHTML;
        var menudiv = document.getElementById('menudiv');
        menudiv.style.left = left;
        menudiv.style.width = width;
    
        if ( menudiv.style.height < '120px' )
        {
            menudiv.style.height = menudiv.style.height + '20px';
            setTimeout("showMenu(menuselect)", 50);
        }
    }    
    </script>
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  9. #9
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Thanks for that, it does work but I've decided agaist that idea now

    Always helps to learn though

  10. #10
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by DJ P@CkMaN
    Thanks for that, it does work but I've decided agaist that idea now
    Bloody Aussies
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  11. #11
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Lol, nah, I'm going to pay someone to do the site for me. It really need to be more professional than I can do it anyway.

  12. #12
    SitePoint Zealot XzAzX's Avatar
    Join Date
    Apr 2002
    Location
    Holland
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    left = menu.style.left
    U forgot the ; on the end

    Code:
    left = menu.style.left;
    _o_ OOP _o_


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
  •