JS+JSP checkBox 全选具体实现
<script>
function func(){
var options=document.getElementsByName("chkBox");
for (var i=0;i<options.length;i++){
if(!options[i].disabled){
options[i].checked=true;
}
}
}
</script>
<input type=checkbox name=chkBox value=1 disabled>
<input type=checkbox name=chkBox value=1>
<input type=checkbox name=chkBox value=1>
<input type=checkbox name=chkBox value=1>
<input type=button value="测 试" onclick="func()">
<html>
<body>
<script>
function kk(){
var handleEl = document.getElementById("kkHandler");
var els = document.getElementsByName("kk");
for(i=0;i<els.length;i++){
els[i].checked = handleEl.checked;
}
}
</script>
<input type=checkbox onclick="kk()" name="kkHandler">全选<br>
<input type=checkbox name="kk">
<input type=checkbox name="kk">
</body>
</html>
<form name="form" ID="Form1">
<input type="checkbox" name="id" value="" ID="Checkbox1">1
<input type="checkbox" name="id" value="" ID="Checkbox2">2
<input type="checkbox" name="chose" value="" onclick="selectAll()" ID="Checkbox5">allselect
</form>
<script>
function selectAll()
{
if(!document.form.id.length){
if(document.form.chose.checked){
document.form.id.checked=true;
}
else{
document.form.id.checked=false;
}
}
else{
for(var i=0;i<document.form.id.length;i++){
if(document.form.chose.checked){
document.form.id[i].checked=true;
}
else{
document.form.id[i].checked=false;
}
}
}
}
</script>
<input type='checkbox' name='info' value='a'>
<input type='checkbox' name='info' value='b'>
<input type='checkbox' name='info' value='c'>
<input type='checkbox' name='info' value='d'>
<input type='checkbox' name='info' value='e'><br>
<input type='button' value =' 全选 'onclick='check_all();'>
<script>
function check_all(){
arr = document.getElementsByName('info');
for(i=0;i<arr.length;i++){
arr[i].checked = true;
}
}
</script>