看看这个:
<html>
<head>
<script language="javascript">
function updata()
{
var c=document.all('td01').children;
for(i=0;i<c.length;i++)
{
(event.srcElement.checked)==true?document.all('td01').children[i].checked=true:document.all('td01').children[i].checked=false;
}
}function updata1()
{
var c=document.all('td01').children;
var temp=true;
for(i=0;i<c.length;i++)
{
if(c[i].checked)
{
temp=true;
break;
}
else
{
temp=false;
}
}
temp==true?form1.a.checked=true:form1.a.checked=false;
}
</script>
</head>
<body>
<table border=1>
<form name="form1">
<tr>
<td><input type="checkbox" name=a onclick="updata()" value="a">a</td>
<td id="td01"><input type="checkbox" onclick="updata1()" name=1 value="1">1
<input type="checkbox" name=2 onclick="updata1()" value="2">2
<input type="checkbox" name=3 onclick="updata1()" value="3">3
<input type="checkbox" name=4 onclick="updata1()" value="4">4
</td>
</tr>
</form>
</table>
</body>
</html>
<html>
<head>
<script language="javascript">
function updata()
{
var c=document.all('td01').children;
for(i=0;i<c.length;i++)
{
(event.srcElement.checked)==true?document.all('td01').children[i].checked=true:document.all('td01').children[i].checked=false;
}
}function updata1()
{
var c=document.all('td01').children;
var temp=true;
for(i=0;i<c.length;i++)
{
if(c[i].checked)
{
temp=true;
break;
}
else
{
temp=false;
}
}
temp==true?form1.a.checked=true:form1.a.checked=false;
}
</script>
</head>
<body>
<table border=1>
<form name="form1">
<tr>
<td><input type="checkbox" name=a onclick="updata()" value="a">a</td>
<td id="td01"><input type="checkbox" onclick="updata1()" name=1 value="1">1
<input type="checkbox" name=2 onclick="updata1()" value="2">2
<input type="checkbox" name=3 onclick="updata1()" value="3">3
<input type="checkbox" name=4 onclick="updata1()" value="4">4
</td>
</tr>
</form>
</table>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货