function public_GetParentByTagName(element, tagName)
{
var parent = element.parentNode;
var upperTagName = tagName.toUpperCase();
//If this element is not wanted yet Continue tracing up to the tag you want
while (parent && (parent.tagName.toUpperCase() != upperTagName))
{
parent = parent.parentNode ? parent.parentNode : parent.parentElement;
}
Return parent;
}
//Set the node's parent node Cheched - if the node is accessible, 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 child node uncheched - this node Inaccessible, then its child nodes are also inaccessible
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")
, Then its child nodes can also access
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.chcked = TRUE;
}
Setchildchecked (tempobj);
}
}> // Triggering events
Function Chevent ()
{ 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")); = document.getElementById(objID "ノード");
if(objParentDiv==null || objParentDiv == "未定義") UnChecked(objParentDiv); 🎜> }
}
サーバー コントロール
コードをコピー
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn