<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
OK
<a href="${pageContext.request.contextPath}/index_cdAddPage.action">添加</a>
<input type="button" value="删除" οnclick="doDelete()">
<a href="#" οnclick="updateProd()">修改</a>
<table>
<tr>
<th>序号</th>
<th>姓名</th>
<th>班级</th>
<!-- <td><a href="#" οnclick="selOrUnSel(this)">全选</a></td>
<input type="button" id="othercheck" value="反选"/>-->
<td><a href="#" οnclick="SelectAll()">全选/反选</a></td>
</tr>
<s:iterator value="#request.list" var="s">
<tr>
<td>${s.id}</td><!-- <s:property value="id"/> -->
<td>${s.name}</td><!--<s:property value="s.name"/> -->
<td>${s.className}</td><!-- -->
<!-- <td>
<input type="checkbox" id="seltId" value="?????????????"/>
</td> -->
<td><input name="checkboxid" type="checkbox" value="${s.id}"></td>
</tr>
</s:iterator>
</table>
<script type="text/javascript">
function SelectAll() {
var checkboxs=document.getElementsByName("checkboxid");
for (var i=0;i<checkboxs.length;i++) {
var e=checkboxs[i];
e.checked=!e.checked;
/* if(e.checked==true){
e.checked=false;
}
else{
e.checked=true
}*/
}
}
function selOrUnSel(obj){
if(obj.innerText=="全选"){
obj.innerText="全不选";
$(":checkbox").attr("checked",true);
}else{
obj.innerText="全选";
$(":checkbox").attr("checked",false);
}
}
function doDelete(){
if(confirm("你确定要删除吗?")){
var param=$(":checkbox:checked").serialize();
location.href="index_deleteStudents?"+param;
}
}
function updateProd(){
var obj=$(":checkbox:checked");
if(obj.length==0){
alert("请选择要修改的");
return;
}
if(obj.length>1){
alert("一次只能修改一个");
return;
}
location.href="index_cdUpdatePage.action?checkboxid="+obj[0].value;
}
</script>
</body>
</html>
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
OK
<a href="${pageContext.request.contextPath}/index_cdAddPage.action">添加</a>
<input type="button" value="删除" οnclick="doDelete()">
<a href="#" οnclick="updateProd()">修改</a>
<table>
<tr>
<th>序号</th>
<th>姓名</th>
<th>班级</th>
<!-- <td><a href="#" οnclick="selOrUnSel(this)">全选</a></td>
<input type="button" id="othercheck" value="反选"/>-->
<td><a href="#" οnclick="SelectAll()">全选/反选</a></td>
</tr>
<s:iterator value="#request.list" var="s">
<tr>
<td>${s.id}</td><!-- <s:property value="id"/> -->
<td>${s.name}</td><!--<s:property value="s.name"/> -->
<td>${s.className}</td><!-- -->
<!-- <td>
<input type="checkbox" id="seltId" value="?????????????"/>
</td> -->
<td><input name="checkboxid" type="checkbox" value="${s.id}"></td>
</tr>
</s:iterator>
</table>
<script type="text/javascript">
function SelectAll() {
var checkboxs=document.getElementsByName("checkboxid");
for (var i=0;i<checkboxs.length;i++) {
var e=checkboxs[i];
e.checked=!e.checked;
/* if(e.checked==true){
e.checked=false;
}
else{
e.checked=true
}*/
}
}
function selOrUnSel(obj){
if(obj.innerText=="全选"){
obj.innerText="全不选";
$(":checkbox").attr("checked",true);
}else{
obj.innerText="全选";
$(":checkbox").attr("checked",false);
}
}
function doDelete(){
if(confirm("你确定要删除吗?")){
var param=$(":checkbox:checked").serialize();
location.href="index_deleteStudents?"+param;
}
}
function updateProd(){
var obj=$(":checkbox:checked");
if(obj.length==0){
alert("请选择要修改的");
return;
}
if(obj.length>1){
alert("一次只能修改一个");
return;
}
location.href="index_cdUpdatePage.action?checkboxid="+obj[0].value;
}
</script>
</body>
</html>