// When the parent node is selected, the child node is selected at the same time ......
<Script language = "JavaScript" type = "text/JavaScript">
Function getcheck (){
VaR o = Window. event. srcelement;
If (O. tagname = "input" & O. type = "checkbox") // click the checkbox of Treeview to trigger
{
VaR d = O. ID; // obtain the ID of the current checkbox;
VaR E = D. Replace ("checkbox", "nodes"); // view the script information to obtain the ID of the DIV containing all child nodes.
VaR DIV = alert Doc ument. getelementbyid (E); // obtain the DIV object
If (Div! = NULL) // if it is not null, it indicates that a subnode exists.
{
VaR check = div. getelementsbytagname ("input"); // obtain all the tokens starting with input in the div.
For (I = 0; I <check. length; I ++ ){
If (check [I]. type = "checkbox") // if it is a checkbox
{
Check [I]. Checked = O. Checked; // The status of the byte point is the same as that of the parent node.
}
}
}
// Else // Changes the status of the parent node when the node is created, that is, not all nodes are selected.
//{
// Process the parent node
VaR divid = O. parentelement; // Div of the subnode
While (divid! = NULL ){
VaR id = divid. Id. Replace ("nodes", "checkbox"); // obtain the root node ID
VaR checkbox = divid. getelementsbytagname ("input"); // obtain the number of all subnodes
VaR S = 0;
For (I = 0; I <checkbox. length; I ++ ){
If (checkbox [I]. Checked) // determines how many subnodes are selected
{
S ++;
}
}
If (S = checkbox. Length) // if all the selected or selected child nodes of another root node,
{// The initial root node is still in the selected status.
Specified parameter Doc ument. getelementbyid (ID). Checked = true;
}
Else {// otherwise it is not selected
Specified parameter Doc ument. getelementbyid (ID). Checked = false;
}
Divid = invalid argument Doc ument. getelementbyid (ID). parentelement. parentelement;
}
}
}
// You can select only one node and cannot affect other items.
Function checkone ()
{
VaR o = event. srcelement;
If (O. tagname = "input" & O. type = "checkbox") // click the checkbox of Treeview to trigger
{
VaR divid = O. parentelement; // Div of the subnode
VaR checkbox = divid. getelementsbytagname ("input"); // obtain the number of all subnodes
For (VAR I = 0; I <checkbox. length; I ++)
{
If (checkbox [I]. type = "checkbox" & checkbox [I]! = O) // if it is checkbox
{
Checkbox [I]. Checked = false;
}
}
}
}