Functionpublic_GetParentByTagName (element, tagName) {varparentelement. parentNode; varupperTagNametagName. toUpperCase (); // if this element is not the expected tag, continue to the while (parent...
Function public_GetParentByTagName (element, tagName)
{
Var parent = element. parentNode;
Var upperTagName = tagName. toUpperCase ();
// If this element is not the desired tag, continue to trace
While (parent & (parent. tagName. toUpperCase ()! = UpperTagName ))
{
Parent = parent. parentNode? Parent. parentNode: parent. parentElement;
}
Return parent;
}
// Set the node's parent node Cheched -- this node is accessible, and its parent node must also be accessible.
Function setParentChecked (objNode)
{
Var objParentDiv = public_GetParentByTagName (objNode, "div ");
If (objParentDiv = null | objParentDiv = "undefined ")
{
Return;
}
Var objID = objParentDiv. getAttribute ("ID ");
ObjID = objID. substring (0, objID. indexOf ("Nodes "));
ObjID = objID + "CheckBox ";
Var objParentCheckBox = document. getElementById (objID );
If (objParentCheckBox = null | objParentCheckBox = "undefined ")
{
Return;
}
If (objParentCheckBox. tagName! = "INPUT" & objParentCheckBox. type = "checkbox ")
Return;
ObjParentCheckBox. checked = true;
SetParentChecked (objParentCheckBox );
}
// Set the node's subnode uncheched -- this node is not accessible, and its subnodes are not accessible.
Function setChildUnChecked (divID)
{
Var objchild = divID. children;
Var count = objchild. length;
For (var I = 0; I
{
Var tempObj = objchild [I];
If (tempObj. tagName = "INPUT" & tempObj. type = "checkbox ")
{
TempObj. checked = false;
}
SetChildUnChecked (tempObj );
}
}
// Set the node's subnode cheched -- this node can be accessed, and its subnodes can also be accessed.
Function setChildChecked (divID)
{
Var objchild = divID. children;
Var count = objchild. length;
For (var I = 0; I
{
Var tempObj = objchild [I];
If (tempObj. tagName = "INPUT" & tempObj. type = "checkbox ")
{
TempObj. checked = true;
}
SetChildChecked (tempObj );
}
}
// Trigger the event
Function CheckEvent ()
{
Var objNode = event. srcElement;
If (objNode. tagName! = "INPUT" | objNode. type! = "Checkbox ")
Return;
If (objNode. checked = true)
{
SetParentChecked (objNode );
Var objID = objNode. getAttribute ("ID ");
Var objID = objID. substring (0, objID. indexOf ("CheckBox "));
Var objParentDiv = document. getElementById (objID + "Nodes ");
If (objParentDiv = null | objParentDiv = "undefined ")
{
Return;
}
SetChildChecked (objParentDiv );
}
Else
{
Var objID = objNode. getAttribute ("ID ");
Var objID = objID. substring (0, objID. indexOf ("CheckBox "));
Var objParentDiv = document. getElementById (objID + "Nodes ");
If (objParentDiv = null | objParentDiv = "undefined ")
{
Return;
}
SetChildUnChecked (objParentDiv );
}
}
Server Control
This. tvPrivilege. Attributes. Add ("OnClick", "CheckEvent ()");
From happy pig's column