<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery.js"></script>
<script>
$(function(){
function inputchecked(obj,id,inputIdString,LableIDString){
var thisId='';//当前选中和ID
var thisNextId='';
var Arr=Array();
var idArr=Array();
//获取选种的id
if(id==null || id==""){
$("#"+obj+" input:checked").each(function(){
thisId+=$(this).attr("id")+",";
})
thisId=thisId.substr(0,thisId.length-1).split(",");
}else{
id=id+',';
thisId=id.substr(0,id.length-1).split(",");
for(var s=0;s<thisId.length;s++){
$("#"+obj+" #"+thisId[s]+"").attr('checked',true)
}
}
for(var m=0;m<thisId.length;m++){
thisNextId=thisId[m].replace(inputIdString,LableIDString);
if($("#"+obj+" #"+thisId[m]+"").attr('checked')=='checked'){
$("#"+obj+" #"+thisNextId+" input").attr('checked',true);
}else{
$("#"+obj+" #"+thisNextId+" input").attr('checked',false);
}
var arr=thisId[m].split("-");
i=arr.length;//当前选择是级数
while(i>0){
Arr[i]=thisId[m].substr(0,thisId[m].length-2*i);
i--;
}
Arr.splice(0,1);
for(var j=0;j<Arr.length-1;j++){
Arr[j]=Arr[j].replace(inputIdString,LableIDString);
//alert(Arr[j]+"||||||"+$("#"+Arr[j]+" input:checked").length)
if($("#"+obj+" #"+Arr[j]+" input:checked").length>0){
$("#"+obj+" #"+Arr[j].replace(LableIDString,inputIdString)+"").attr("checked",true)
}else{
$("#"+obj+" #"+Arr[j].replace(LableIDString,inputIdString)+"").attr("checked",false)
}
}
}
}
$("#t input").bind('click',function(){
inputchecked('t',thisId=$(this).attr("id"),'s','v');
})
//inputchecked("t",'','s','v');
$("#j input").bind('click',function(){
inputchecked('j',thisId=$(this).attr("id"),'s','v');
})
inputchecked("j",'s1-1-2-1,s1-1-1-2','s','v');
})
</script>
</head>
<body>
<table width="917" border="1" id='t'>
<tr>
<td width="204" height="518"><input type='checkbox' id='s1'/>1</td>
<td width="697">
<label id='v1'>
<table width="675" border="1">
<tr>
<td width="42" height="115"><input type='checkbox' id='s1-1'/>1-1</td>
<td width="617">
<label id='v1-1'>
<table width="447" border="1">
<tr>
<td width="92" height="139"><input type='checkbox' id='s1-1-1'/>1-1-1</td>
<td width="339">
<label id='v1-1-1'>
<table width="312" border="1">
<tr>
<td><input type='checkbox' id='s1-1-1-1'/>1-1-1-1</td>
<td><input type='checkbox' id='s1-1-1-2' />1-1-1-2</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
<table width="447" border="1">
<tr>
<td width="92" height="139"><input type='checkbox' id='s1-1-2'>1-1-2</td>
<td width="339">
<label id='v1-1-2'>
<table width="312" border="1">
<tr>
<td><input type='checkbox' id='s1-1-2-1'/>1-1-2-1</td>
<td><input type='checkbox' id='s1-1-2-2'/>1-1-2-2</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
<table width="675" border="1">
<tr>
<td width="42" height="115"><input type='checkbox' id='s1-2'>
1-2</td>
<td width="617">
<label id='v1-2'>
<table width="447" border="1">
<tr>
<td width="92" height="139"><input type='checkbox' id='s1-2-1'>
1-2-1</td>
<td width="339">
<label id='v1-2-1'>
<table width="312" border="1">
<tr>
<td><input type='checkbox' id='s1-2-1-1'/>
1-2-1-1</td>
<td><input type='checkbox' id='s1-2-1-2'/>
1-2-1-2</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
</label>
</td></tr>
</table>
<table width="917" border="1" id='j'>
<tr>
<td width="204" height="518"><input type='checkbox' id='s1'/>1</td>
<td width="697">
<label id='v1'>
<table width="675" border="1">
<tr>
<td width="42" height="115"><input type='checkbox' id='s1-1'/>1-1</td>
<td width="617">
<label id='v1-1'>
<table width="447" border="1">
<tr>
<td width="92" height="139"><input type='checkbox' id='s1-1-1'/>1-1-1</td>
<td width="339">
<label id='v1-1-1'>
<table width="312" border="1">
<tr>
<td><input type='checkbox' id='s1-1-1-1'/>1-1-1-1</td>
<td><input type='checkbox' id='s1-1-1-2' />1-1-1-2</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
<table width="447" border="1">
<tr>
<td width="92" height="139"><input type='checkbox' id='s1-1-2'>1-1-2</td>
<td width="339">
<label id='v1-1-2'>
<table width="312" border="1">
<tr>
<td><input type='checkbox' id='s1-1-2-1'/>1-1-2-1</td>
<td><input type='checkbox' id='s1-1-2-2'/>1-1-2-2</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
<table width="675" border="1">
<tr>
<td width="42" height="115"><input type='checkbox' id='s1-2'>
1-2</td>
<td width="617">
<label id='v1-2'>
<table width="447" border="1">
<tr>
<td width="92" height="139"><input type='checkbox' id='s1-2-1'>
1-2-1</td>
<td width="339">
<label id='v1-2-1'>
<table width="312" border="1">
<tr>
<td><input type='checkbox' id='s1-2-1-1'/>
1-2-1-1</td>
<td><input type='checkbox' id='s1-2-1-2'/>
1-2-1-2</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
</label>
</td>
</tr>
</table>
</label>
</td></tr>
</table>
</body>
</html>