代码:
<tr><td>用户权限:</td>
<td>
<select id="userRight" id="groupRight" name="groupRight" style="width:200px;" οnchange="selecgRight(this);">
<option value="1">系统管理员</option>
<option value="2">普通用户</option>
<option value="3">自定义权限</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="checkbox" value="1" checked name="userGroupRight">查询本人导入的检查记录</input><br>
<input type="checkbox" value="2" checked name="userGroupRight">查询所有检查记录</input><br>
<input type="checkbox" value="3" checked name="userGroupRight">查询本人的操作日志</input><br>
<input type="checkbox" value="4" checked name="userGroupRight">查询所有操作日志</input><br>
<input type="checkbox" value="5" checked name="userGroupRight">修改用户密码</input><br>
<input type="checkbox" value="6" checked name="userGroupRight">管理用户</input>
</td>
</tr>
function selecgRight(obj){
var curValue=obj.value;
if(curValue==1){
//选中所有的复选框
$("[name='userGroupRight']").attr("checked",'true');
}else if(curValue==2){
$("[name='userGroupRight']").removeAttr("checked");
$("[name='userGroupRight']").each(function(){
if($(this).val()==1){
$(this).attr("checked",'true');
}
if($(this).val()==3){
$(this).attr("checked",'true');
}
if($(this).val()==5){
$(this).attr("checked",'true');
}
})
}else{
//取消所有复选框
$("[name='userGroupRight']").removeAttr("checked");
}
}