function public_GetParentByTagName(element, tagName)
{
var parent = element.parentNode; 要的tag繼續上溯
while (parent && (parent.tagName.toUpperCase() != upperTagName))
{
}
return parent;
}
//設定節點的父節點Cheched-該節點可訪問,則他的父節點也必能存取
function setParentChecked(objNode)
{
var objParentDiv = public_GetParentByTagName(objNode,"div");
if(objParentDiv==null || objParentDiv== "undefined") 🎜> }
var objID = objParentDiv.getAttribute("ID");
objID = objID.substring(0,objID.indexOf("Nodes"));
遠 | getElementById(objID);
if(objParentCheckBox==null || objParentCheckBox == "undefined")
{
entCheckBox.tagName!="INPUT" && objParentCheckBox.type == "checkbox")
return;
objParentCheckBox.checked = true;
setParentChecked(objParCheckBox);不可訪問,則他的子節點也不能訪問
function setChildUnChecked(divID)
{
var objchild = divID.children;
=0;i {
var tempObj = objchild[i];
🎜> {
tempObj.checked = false;
🎜> }
}
//設定節點的子節點cheched-此節點可以訪問,則他的子節點也都能存取
function setChildChecked(divID)
{
var objchild = divID.children;
;i {
var tempObj = objchild[i];
{
tempObj.checked = true;
}
>//觸發事件
function CheckEvent()
{
var objNode = event.srcElement;
if(objNode.tagName!="INPUT" || objNode.type!="checkbox")
🎜> {
setParentChecked(objNode);
var objID = objNode.getAttribute( (0,objID.indexOf("CheckBox"));
var objParentDiv = document.getElementById(objID "Nodes");
if(objParentTiv==null || objPar if(objParentDiv==null || objPar 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") UnChecked(objParentDiv);
}
}
Server control
Copy code