- /**
- * 实现复选框的全选/全不选
- */
- sysuser.select = function(){
- for (var i=0;i<box.length;i++ ){
- box[i].checked=!box[i].checked;
- }
- };
js得到选中复选框的值
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js得到选中复选框的值</title>
</head>
<body>
<form>
<input type="checkbox" id="box" name="1" value="1"/>
<input type="checkbox" id="box" name="2" value="2"/>
<input type="checkbox" id="box" name="3" value="3"/>
<input type="checkbox" id="box" name="4" value="4"/>
<input type="button" value=" 测 试 " onclick="sysuser.select()"/>
<form>
<body>
<html>
* 得到选中复选框的值
*/
sysuser.select = function(){
var value="";
for (var i=0;i<box.length;i++ ){
if(box[i].checked){
value += box[i].value + ",";
}
}
value = value.substring(0,value.length-1);
alert(value);
};