Entry
How can I script a hierarchical list of checkboxes?
How can I script a hierarchical list of checkboxes?
Apr 22nd, 2000 03:52
Martin Honnen,
The following gives an example for IE4+ and NN6 on how to toggle the
display property on a DIV element to alternatively display a list of
checkboxes:
<HTML>
<HEAD>
<STYLE>
.subOptions {
display: none;
margin-left: 20px;
}
</STYLE>
<SCRIPT>
function toggleOptions (checkbox) {
var id = 'subOptions' + checkbox.name;
var subOptions =
document.all ? document.all[id] :
document.getElementById ? document.getElementById(id) :
null;
if (subOptions) {
if (subOptions.style.display == '' ||
subOptions.style.display == 'none')
subOptions.style.display = 'block';
else
subOptions.style.display = 'none';
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="formName">
<INPUT TYPE="checkbox" NAME="option0"
ONCLICK="toggleOptions(this)"
>
www.FAQTs.com user
<DIV ID="subOptionsoption0" CLASS="subOptions">
<INPUT TYPE="checkbox" NAME="option00"
>
JavaScript.FAQTs.com user
<BR>
<INPUT TYPE="checkbox" NAME="option01"
>
PHP.FAQTs.com user
<BR>
<INPUT TYPE="checkbox" NAME="option02"
>
Python.FAQTs.com user
</DIV>
<BR>
<INPUT TYPE="checkbox" NAME="option1"
ONCLICK="toggleOptions(this)"
>
<DIV ID="subOptionsoption1" CLASS="subOptions">
<INPUT TYPE="checkbox" NAME="option10"
>
<BR>
<INPUT TYPE="checkbox" NAME="option11"
>
<BR>
<INPUT TYPE="checkbox" NAME="option12"
>
</DIV>
<BR>
</FORM>
</BODY>
</HTML>
A solution for NN4 would requiring breaking up the form into several
ones contained in layers whose content you rewrite or whose visibility
you toggle.