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.

    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");
            cltPlusMinus.src = cltPlusMinus.src.replace("minus.gif", "plus.gif");
        if (cltProjects != undef)
            if (cltProjects.length == undef)
            else if (cltProjects.length > 0)
                for (var i = 0; i < cltProjects.length; i++)

And the HTML using this function is:

<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…

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.

There is nohting in the HTML with an id of “clt” + cltID + “Project” so what you posted is definitely missing that part.

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.

Hi Felgal,

Here is the HTML:

<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 %>>


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.

Generated HTML

already solved this one. the solution was:

getElementById(“clt” + cltID + “Project”);


getElementById(“plusMinus” + cltID);