<script language="javaScript">
//全选或全部不选
function checkall(){
var isChecked=(document.testForm.checkAll.checked == true);
var elements=document.testForm.elements;
var counter=elements.length;
for(i=0;i<counter;i++){
var element=elements[i];
if(element.type=="checkbox"){
element.checked=isChecked;
}
}
}
//是否有checkbox被选中
function anyBodyChecked(){
var elements=document.testForm.elements;
var counter=elements.length;
for(i=0;i<counter;i++){
var element=elements[i];
if(element.checked == true){
return true;
}
}
return false;
}
</script>
<form name="testForm">
全选:
<input type="checkbox" id="checkAll"onclick="checkall()" />
多项选择框列表:
<input type="checkbox" name="checkbox" value="1" />
<input type="checkbox" name="checkbox" value="2"/>
<input type="checkbox" name="checkbox" value="3"/>
</form>
//实际保护值{"1","2","3"}
String[] checkBoxs = request.getParameterValues("checkbox");
//其他的就不用写了,Iterator取值就行了.