<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'list.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function(){
//全选
$("[value='全选']").click(function(){
$(".ch").attr("checked",true);
});
//全不选
$("[value='全不选']").click(function(){
$(".ch").attr("checked",false);
});
//反选
$("[value='反选']").click(function(){
$(".ch").each(function(){
if($(this).attr("checked")){
$(this).attr("checked",false);
}else{
$(this).attr("checked",true);
}
});
});
//添加
$("[value='添加']").click(function(){
location="add.jsp";
});
//批量删除
$("[value='批量删除']").click(function(){
var res = "";
$(".ch").each(function(){
if($(this).attr("checked")){
res += ","+$(this).val();
}
});
var ids = res.substring(1);
if(confirm("是否确认删除?")){
// location="&ids="+ids;
$.ajax({
url:"emp?m=dels",
type:"post",
data:{ids:ids},
dataType:"text",
success:function(msg){
if(msg>0){
location="emp?m=list";
}else{
location.reload();
}
}
});
}else{
alert("已取消");
}
});
});
function upd(id){
location="upd.jsp?id="+id;
}
</script>
</head>
<body>
<table border="1px">
<tr>
<th></th>
<th>eid</th>
<th>ename</th>
<th>age</th>
<th>sex</th>
<th>hobby</th>
<th>birthday</th>
<th><input type="button" value="添加"></th>
</tr>
<c:forEach var="li" items="${list}">
<tr>
<th><input type="checkbox" class="ch" value="${li.eid}"></th>
<th>${li.eid}</th>
<th>${li.ename}</th>
<th>${li.age}</th>
<th>${li.sex}</th>
<th>${li.hobby}</th>
<th>${li.birthday}</th>
<th><input type="button" value="修改" onclick="upd(${li.eid})"></th>
</tr>
</c:forEach>
</table>
<input type="button" value="全选">
<input type="button" value="全不选">
<input type="button" value="反选">
<input type="button" value="批量删除">
</body>
</html>
海纳百川,有容乃大。壁立千仞,无欲则刚。