Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape's DOM, how to check/uncheck checkboxes

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I have this so far (top half being "IF" it's IE)

[tt]
<% if instr(ucase(Request.ServerVariables(&quot;HTTP_USER_AGENT&quot;)), &quot;MSIE&quot;) <> 0 then %>
if (document.all(tree[j][2]).length > 1)
{
for (i=0; i<document.all(tree[j][2]).length; i++)
document.all(tree[j][2],i).checked = status;
}
else
{
document.all(tree[j][2]).checked = status;
}
<% else %>
if (document.layers(tree[j][2]).length > 1)
{
for (i=0; i<document.layers(tree[j][2]).length; i++)
document.layers(tree[j][2],i).checked = status;
}
else
{
document.layers(tree[j][2]).checked = status;
}
<% end if %>
[/tt]

so far I've tried .forms[index], .forms, .layers, and so forth, but nothing works, IE works perfectly. [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
I got this to &quot;show something&quot; with netscape without an error, however it doesnt even behave correctly, not doing what I Want it to do

if (document.forms[0][tree[j][2]].length > 1)
{
for (i=0; i<document.forms[0][tree[j][2]].length; i++)
if (document.forms[0][tree[j][2],i].value == tree[j][5])
document.forms[0][tree[j][2],i].checked = true;
}
else
{
document.forms[0][tree[j][2]].checked = true;
}

(for the showchild one, replace 'true' with 'status')
[sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
here are the two full functions, highlighting the netscape portion:

[tt]
function ShowChild(HID, LID, status)
{
var list = '';
for(var j=0; j<=max; j++)
{
if ((tree[j][3] == HID) & (tree[j][4] == LID))
{
<% if instr(ucase(Request.ServerVariables(&quot;HTTP_USER_AGENT&quot;)), &quot;MSIE&quot;) <> 0 then %>
if (document.all(tree[j][2]).length > 1)
{
for (i=0; i<document.all(tree[j][2]).length; i++)
document.all(tree[j][2],i).checked = status;
}
else
{
document.all(tree[j][2]).checked = status;
}
<% else %>[red]
if (document.forms[0][tree[j][2]].length > 1)
{
for (i=0; i<document.forms[0][tree[j][2]].length; i++)
if (document.forms[0][tree[j][2],i].value == tree[j][5])
document.forms[0][tree[j][2],i].checked = status;
}
else
{
document.forms[0][tree[j][2]].checked = status;
}[/red]
<% end if %>
ShowChild(tree[j][0],tree[j][1], status);
}
}
}

function ShowParent(HP, LP)
{
var list = '';
for(var j=0; j<=max; j++)
{
if ((tree[j][0] == HP) & (tree[j][1] == LP))
{
<% if instr(ucase(Request.ServerVariables(&quot;HTTP_USER_AGENT&quot;)), &quot;MSIE&quot;) <> 0 then %>
if (document.all(tree[j][2]).length > 1)
{
for (i=0; i<document.all(tree[j][2]).length; i++)
if (document.all(tree[j][2],i).value == tree[j][5])
document.all(tree[j][2],i).checked = true;
}
else
{
document.all(tree[j][2]).checked = true;
}
<% else %>
[red] if (document.forms[0][tree[j][2]].length > 1)
{
for (i=0; i<document.forms[0][tree[j][2]].length; i++)
if (document.forms[0][tree[j][2],i].value == tree[j][5])
document.forms[0][tree[j][2],i].checked = true;
}
else
{
document.forms[0][tree[j][2]].checked = true;
}[/red]
<% end if %>
ShowParent(tree[j][3],tree[j][4]);
}
}
}
[/tt]

The IE portion works flawlessly, it checks any parent checkboxes, as well as child, where as netscape is erratic, if I check a second level it doesnt check child, or parent, and if I try to uncheck that same 2nd level, it wont uncheck, also checking main parent will only check 1st level children and not go further below, I dont know why Netscape is being such a pain. [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top