代码如下:
<html>
<head>
<title>制作全选效果</title>
<script language="javascript">
function selectAll(){
allcheckBoxs=document.getElementsByName("dushan");
var dushan2=document.getElementsByName("dushan1");
if(dushan2[0].checked){
for(var i=0;i<allcheckBoxs.length;i++){
allcheckBoxs[i].checked = true;
}
}else{
for(var i=0;i<allcheckBoxs.length;i++){
allcheckBoxs[i].checked = false;
}
}
}
</script>
</head>
<body>
<form name="myform">
<table>
<tr>
<td><input type="checkbox" name="dushan1" onclick="selectAll()" />全选/全不选</td>
<td> <img src="images/top.jpg"/></td>
</tr>
<tr><td><input type="checkbox" name="dushan" /></td><td><img src="images/one.jpg"/></td></tr>
<tr><td><input type="checkbox" name="dushan" /></td><td><img src="images/two.jpg"/></td></tr>
<tr><td><input type="checkbox" name="dushan" /></td><td><img src="images/three.jpg"/></td></tr>
<tr><td><input type="checkbox" name="dushan" /></td><td><img src="images/four.jpg"/></td></tr>
</table>
</form>
</body>
</html>
|