function save(){ $('form').submit(); window.open('<%=path%>/student.do?method=findAll','main'); }
function deleteIt(id){ var flag = window.confirm("确定要删除该学员吗?"); if(flag){ window.open('<%=path%>/student.do?method=deleteStudent&id='+id,'main'); alert("删除成功!"); } }
function addStudent(){ $('#addDialog').dialog('open'); } </script> </head>
$('form').submit();
window.open('<%=path%>/student.do?method=findAll','main');
}
function deleteIt(id){
var flag = window.confirm("确定要删除该学员吗?");
if(flag){
window.open('<%=path%>/student.do?method=deleteStudent&id='+id,'main');
alert("删除成功!");
}
}
function addStudent(){
$('#addDialog').dialog('open');
}
</script>
</head>
<body>
<div id="container">
<div id="header">
<h1>学员信息列表</h1>
<p align="right"><img src="<%=path%>/images/back.gif" style="cursor: pointer;" onclick="window.history.back()"/></p>
</div>
<div id="mainContext">
<form action="student.do" method="post">
<table>
<thead>
<tr>
<th>序号</th>
<th>学好</th>
<th>姓名</th>
<th>性别</th>
<th>出生日期</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:if test="${empty list}">
<tr><td colspan="6">暂时没有学员</td></tr>
</c:if>
<c:forEach items="${list}" var="student" varStatus="index">
<tr>
<td>${index.index+1}</td>
<td>${student.id}</td>
<c:if test="${param.editId eq student.id}" var="hy">
<td><input name="name" value="${student.name}"></td>
<td>
<input name="gender" type="radio" value="0" <c:if test="${student.gender eq 0}">checked</c:if> >男
<input name="gender" type="radio" value="1" <c:if test="${student.gender eq 1}">checked</c:if>>女
</td>
<td><input name="birthday" class="adate" value="<fm:formatDate value="${student.birthday}" pattern="yyyy-MM-dd"/>"></td>
<td>
<input type="hidden" name="method" value="editStudent">
<input type="hidden" name="id" value="${student.id}">
<a href="#" onclick="save();return false;">保存</a>
<a href="<%=path%>/student.do?method=findAll">取消</a>
</td>
</c:if>
<td>${student.name}</td>
<td>${student.gender == 0?"男":"女"}</td>
<td><fm:formatDate value="${student.birthday}" pattern="yyyy年MM月dd日"/></td>
<td>
<a href="<%=path%>/student.do?method=findAll&editId=${student.id}">修改</a>
<a href="#" onclick="deleteIt('${student.id}');return false;">删除</a>
<a href="<%=path%>/student.do?method=findCourseById&id=${student.id}">选修的课程</a>
</td>
</c:if>
</tr>
</c:forEach>
</tbody>
</table>
</form>
</div>
<button onclick="addStudent();return false;">添加新学员</button>
<div id="addDialog" title="添加新学员" style="display: none;">
<table>
<caption>新学员信息</caption>
<tr>
<td width="30%">学 号:</td>
<td><input id="id"></td>
</tr>
<tr>
<td>姓 名:</td>
<td><input id="name"></td>
</tr>
<tr>
<td>性 别:</td>
<td><input name="gender" type="radio" value="0">男 <input name="gender" type="radio" value="1">女</td>
</tr>
<tr>
<td>出生日期:</td>
<td><input id="birthday" class="date"></td>
</tr>
<tr>
<td>选修课程:</td>
<td>
<c:forEach items="${courses}" var="course" varStatus="index">
<input type="checkbox" id="course" value="${course.id}">${course.name}
<c:if test="${(index.index+1)%4 == 0 && index.index != 0}"><br></c:if>
</c:forEach>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>