js 권한 트 리 의 업데이트 권한 을 실현 할 때 전체 선택 취소 기능


// JScript
function getParentByTagName(element,tagName)
{
var parent = element.parentNode;
var upperTagName = tagName.toUpperCase();
while (parent && (parent.tagName.toUpperCase() != upperTagName))
{
parent = parent.parentNode ? parent.parentNode : parent.parentElement;
}
return parent;
}
function setParentChecked(objNode)
{
var objParentDiv = getParentByTagName(objNode,"div");
if(objParentDiv == null || objParentDiv == "undefined")
return;
var objID = objParentDiv.getAttribute("ID");
var objParentCheckBox = document.getElementById(objID.replace("Nodes","CheckBox"));
if(objParentCheckBox == null || objParentCheckBox == "undefined")
return;
if(objParentCheckBox.tagName!="INPUT" && objParentCheckBox.type == "checkbox")
return;
//add
// if (objNode.checked=false) objPraentCheckBox.checked=false;
// objParentCheckBox.checked = true;
setParentChecked(objParentCheckBox);
}
function setParentUnChecked(objNode)
{
var objParentDiv = getParentByTagName(objNode,"div");
if(objParentDiv == null || objParentDiv == "undefined")
return;
var objID = objParentDiv.getAttribute("ID");
var objParentCheckBox = document.getElementById(objID.replace("Nodes","CheckBox"));
if(objParentCheckBox == null || objParentCheckBox == "undefined")
return;
if(objParentCheckBox.tagName!="INPUT" && objParentCheckBox.type == "checkbox")
return;
//add
// if (objNode.checked=false) objPraentCheckBox.checked=false;
objParentCheckBox.checked = false;
setParentUnChecked(objParentCheckBox);
}
function setChildCheckedState(div,state)
{
var objchild = div.childNodes;
var count = objchild.length;
for(var i=0;i<objchild.length;i++)
{
var tempObj = objchild[i];
if(tempObj.tagName=="INPUT" && tempObj.type == "checkbox")
{
tempObj.checked = state;
}
// debugger;
setChildCheckedState(tempObj,state);
}
}
function TreeNodeChecked()
{
var objNode = window.event.srcElement;
if(objNode.tagName!="INPUT" || objNode.type!="checkbox")
return;
// debugger;
if(objNode.checked == true)
{
setParentChecked(objNode);
}
else
{
setParentUnChecked(objNode);
}
var objID = objNode.getAttribute("ID");
var objParentDiv = document.getElementById(objID.replace("CheckBox","Nodes"));
if(objParentDiv==null || typeof(objParentDiv) == "undefined")
return;
setChildCheckedState(objParentDiv,objNode.checked);
}
function SetTreeNodeChecked(objNode1)
{
var objNode =objNode1;
var objID = objNode.getAttribute("ID");
var objParentDiv = document.getElementById(objID.replace("CheckBox","Nodes"));
if(objParentDiv==null || typeof(objParentDiv) == "undefined")
return;
setChildCheckedState(objParentDiv,objNode.checked);
}
function GetYHQS(id)
{
PageMethods.CallYHQX(id,callsuccessed);
}
function callsuccessed(result)
{
// //
//debugger;
for (i=0;i<document.form1.length ;i++)
{
var objNode=document.form1.elements[i];
if (objNode.tagName=="INPUT" && objNode.type=="checkbox")
{
objNode.checked=false;
}
}
for (i=0;i<document.form1.length ;i++)
{
var objNode=document.form1.elements[i];
if (objNode.tagName=="INPUT" && objNode.type=="checkbox")
{
//
//
if (result.indexOf(objNode.title)!=-1)
{
objNode.checked=true;
SetTreeNodeChecked(objNode);
}
}
}
}
function test()
{
debugger;
//
for (i=0;i<document.form1.length ;i++)
{
var objNode=document.form1.elements[i];
if (objNode.tagName=="INPUT" && objNode.type=="checkbox")
{
//
//
objNode.checked=true;
}
}
}

좋은 웹페이지 즐겨찾기