TreeView中选择父级checkbox时,子级连动
function SelectChild()
{
var obj = event.srcElement;
if(obj.type == "checkbox")
{
do
{
obj = obj.parentElement;
}
while(obj.tagName != "TABLE");
CheckedInput(obj.nextSibling,event.srcElement.checked);
}
}
//选择Div(父节点)内所有input
function CheckedInput(obj,t)
{
var tbs = obj.getElementsByTagName("TABLE");
var i,l;
for(i = 0 , l = tbs.length ; i < l ; ++i)
{
tbs[i].rows(0).cells(2).childNodes[0].checked = t;
}
}
------解决方案--------------------
JScript code
function SelectCheckBox()
{
var ele = event.srcElement;
//单击节点上的CheckBox获取所有子节点
if(ele.type=='checkbox')
{
var childrenDivID = ele.id.replace('CheckBox','Nodes');
var div = document.getElementById(childrenDivID);
if(div!=null)
{
var checkBoxs = div.getElementsByTagName('INPUT');
for(var i=0;i<checkBoxs.length;i++)
{
if(checkBoxs[i].type=='checkbox')
{
checkBoxs[i].checked=ele.checked;
}
}
}
}
}