js部分:注意:<script type="text/javascript" ></script>内不能有其他内容,否则会无效,若有则另起一对<script type="text/javascript" ></script>
<script type="text/javascript" >
function demo() {
var allcheck = document.getElementById("allcheck");
var info = document.getElementsByName("info");
for ( var i = 0; i < info.length; i++) {
info[i].checked = allcheck.checked;
}
}
</script>
jsp部分:
批量删除选择部分:
<input type="checkbox" id="allcheck" onclick="demo()" /> <input
type="submit" value="批量删除" onclick="return confirm('确定删除选择项?')"
align="left">
用户部分:
<tr>
<th class="tc" width="5%"></th>
<th>行号</th>
<th>用户编号</th>
<!-- 此处用户编号相当于学生学号,固定不变 -->
<th>用户名</th>
<th>注册人</th>
<th>年龄</th>
<th>性别</th>
<th>编辑</th>
</tr>
<c:forEach items="${list }" var="user" varStatus="stat">
<%-- <c:forEach items="${list }" var="user" > --%>
<!-- varStatus="stat" 用于始终按行号排列 -->
<tr>
<td align="center" class="tc"><input id="${user.uid }"
name="info" value="${user.uid }" type="checkbox"></td>
<td>${stat.count }</td>
<td>${user.uid }</td>
<td>${user.uname }</td>
<td>${user.urealname }</td>
<td>${user.uage }</td>
<td>${user.usex==1?"男":"女" }</td>
<td><a href="edituser?do=editbefore&uid=${user.uid }">修改</a> <a
href="deleteUser?uid=${user.uid }">删除</a></td>
</tr>
</c:forEach>