SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile document.all is undefined

    Hi guys,

    I have this problem, document.all is undefined in Firefox. But when I tried using IE it works fine. I tried replacing document.all to document.getElementById but another problem occur, cltPlusMinus is undefined. Below is the function.

    PHP Code:
        function toggleClient(cltID)
        {
            var 
    cltProjects document.all["clt" cltID "Project"];
            var 
    undef;
            
            var 
    cltPlusMinus document.all["plusMinus" cltID];
            
            if (
    cltPlusMinus.src.indexOf("plus.gif") != -1)
                
    cltPlusMinus.src cltPlusMinus.src.replace("plus.gif""minus.gif");
            else
                
    cltPlusMinus.src cltPlusMinus.src.replace("minus.gif""plus.gif");
            
            if (
    cltProjects != undef)
            {
                if (
    cltProjects.length == undef)
                {
                    
    toggleElement(cltProjects);
                }
                else if (
    cltProjects.length 0)
                {                
                    for (var 
    0cltProjects.lengthi++)
                    {
                        
    toggleElement(cltProjects[i]);
                    }
                
                }
            } 
    And the HTML using this function is:

    PHP Code:
    <td style="border:0px; width:16px; text-align:center;"><a href="javascript:toggleClient(<%= currentClient %>)"><img src="/images/Admin/icons/plus.gif" width="9" height="9" alt="" border="0" name="plusMinus<%= currentClient %>" id="plusMinus<%= currentClient %>" /></a></td

    Thanks in advance...



    Thanks in advance..

  2. #2
    Forums Designer
    Join Date
    Jun 2004
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    document.all is IE-only code, so you should avoid it like a plague and use document.getElementById, which is supported by all browsers.

    I don't see anything with id "cltPlusMinus" in your code, so it is undefined. Probably you forgot to post that part of code. Make sure you do have element with that id somewhere in your code and it will work fine.

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by CyberAlien View Post
    document.all is IE-only code, so you should avoid it like a plague and use document.getElementById, which is supported by all browsers.

    I don't see anything with id "cltPlusMinus" in your code, so it is undefined. Probably you forgot to post that part of code. Make sure you do have element with that id somewhere in your code and it will work fine.
    No, that's all the code, I posted everything there. The "cltPlusMinus" is where the symbol "+" and symbol "-". When you click "+" it shows all the client, "-" it toggles OFF.

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    There is nohting in the HTML with an id of "clt" + cltID + "Project" so what you posted is definitely missing that part.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    Forums Designer
    Join Date
    Jun 2004
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by neo_phyte View Post
    No, that's all the code, I posted everything there. The "cltPlusMinus" is where the symbol "+" and symbol "-". When you click "+" it shows all the client, "-" it toggles OFF.
    That image has id "plusMinus<%= currentClient %>", not "cltPlusMinus"

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by CyberAlien View Post
    That image has id "plusMinus<%= currentClient %>", not "cltPlusMinus"
    So does the loop in the JavaScript. It is the one with Project on the end that is the one that is missing from the HTML.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    So does the loop in the JavaScript. It is the one with Project on the end that is the one that is missing from the HTML.

    Hi Felgal,

    Here is the HTML:

    Code:
    <tr class="<%= TRType & TRClass %>" onmouseover="this.className = 'Highlite<%= TRClass %>';" onmouseout="this.className = '<%= TRType & TRClass %>'" name="clt<%= rs("clt_ID") %>Project" id="clt<%= rs("clt_ID") %>Project" <% if usrType = "master" or usrType = "admin" then %>style="display:none;"<% end if %>>
    Thanks

  8. #8
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by neo_phyte View Post
    Hi Felgal,

    Here is the HTML:

    Code:
    <tr class="<%= TRType & TRClass %>" onmouseover="this.className = 'Highlite<%= TRClass %>';" onmouseout="this.className = '<%= TRType & TRClass %>'" name="clt<%= rs("clt_ID") %>Project" id="clt<%= rs("clt_ID") %>Project" <% if usrType = "master" or usrType = "admin" then %>style="display:none;"<% end if %>>
    Thanks
    Here is the generated HTML...
    Attached Files Attached Files

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,600
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by neo_phyte View Post
    Here is the generated HTML...
    No that isn't the generated HTML - that is some server side language that will be used to generate the HTML as it is filled with <% %> references that will not be there in the generated HTML.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  10. #10
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    No that isn't the generated HTML - that is some server side language that will be used to generate the HTML as it is filled with <% %> references that will not be there in the generated HTML.
    Generated HTML
    Attached Files Attached Files

  11. #11
    SitePoint Enthusiast
    Join Date
    Feb 2010
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    already solved this one. the solution was:

    getElementById("clt" + cltID + "Project");

    and

    getElementById("plusMinus" + cltID);


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
  •