CaptainSensible
Programmer
Hello,
I'm having trouble with a function using recursive programming to uncheck checkboxes, organized as a tree, with parents, child...
As an example:
<LI class="Collection-LI-first">
<INPUT type="checkbox" name="common" value="common" tabindex="debut+3" id="3" parentid="0" onclick="doOnClick(this)">common</INPUT>
<BR></BR>
</LI>
<UL>
<LI class="Collection-LI-first">
<INPUT type="checkbox" name="classes" value="classes" tabindex="debut+4" id="4" parentid="3" onclick="doOnClick(this)">classes</INPUT>
<BR></BR>
</LI>
<UL></UL>
<LI class="Collection-LI-first">
<INPUT type="checkbox" name="lib" value="lib" tabindex="debut+5" id="5" parentid="3" onclick="doOnClick(this)">lib</INPUT>
<BR></BR>
</LI>
<UL></UL>
</UL>
So I use this function to uncheck all the childs, and childs of the childs... but somewhere there is a problem with the pointers and it leads to unexepected behavior.
function ClearChildren(checkboxId) {
for (i=eval(debut); i<collection.elements.length; i++){
var temp=collection.elements;
if (eval(temp.parentid) == eval(checkboxId)){ temp.checked=false;
if (hasChildren(temp)) ClearChildren(temp.id);}
}
}
Could anyone help me out? Thanks in advance.
I'm having trouble with a function using recursive programming to uncheck checkboxes, organized as a tree, with parents, child...
As an example:
<LI class="Collection-LI-first">
<INPUT type="checkbox" name="common" value="common" tabindex="debut+3" id="3" parentid="0" onclick="doOnClick(this)">common</INPUT>
<BR></BR>
</LI>
<UL>
<LI class="Collection-LI-first">
<INPUT type="checkbox" name="classes" value="classes" tabindex="debut+4" id="4" parentid="3" onclick="doOnClick(this)">classes</INPUT>
<BR></BR>
</LI>
<UL></UL>
<LI class="Collection-LI-first">
<INPUT type="checkbox" name="lib" value="lib" tabindex="debut+5" id="5" parentid="3" onclick="doOnClick(this)">lib</INPUT>
<BR></BR>
</LI>
<UL></UL>
</UL>
So I use this function to uncheck all the childs, and childs of the childs... but somewhere there is a problem with the pointers and it leads to unexepected behavior.
function ClearChildren(checkboxId) {
for (i=eval(debut); i<collection.elements.length; i++){
var temp=collection.elements;
if (eval(temp.parentid) == eval(checkboxId)){ temp.checked=false;
if (hasChildren(temp)) ClearChildren(temp.id);}
}
}
Could anyone help me out? Thanks in advance.