📄 student.jsp
字号:
<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="css/shared.css">
<title>
student
</title>
<script language="javascript">
var selectedTr = null;
function setTrColor(colorTr,color)
{
if(colorTr.tagName=="TR")
{
for(var i=0;i<colorTr.childNodes.length;i++)
{
colorTr.childNodes(i).style.backgroundColor = color;
colorTr.childNodes(i).children(0).style.backgroundColor = color;
}
}
}
function addstudent()
{
document.studentActionForm.operation.value = "add";
//alert(document.studentActionForm.operation.value);
document.studentActionForm.submit();
}
function deletestudent()
{
if(selectedTr!=null)
{ //alert(selectedTr.childNodes(0).children(1).value);
if(selectedTr.childNodes(0).children(1).value!=0&&selectedTr.childNodes(0).children(1).value!=null)
{
document.studentActionForm.deleteUID.value = selectedTr.childNodes(0).children(1).value;
document.studentActionForm.operation.value="delete";
studentRows.removeChild(selectedTr);
selectedTr = null;
document.studentActionForm.submit();
}else
{
studentRows.removeChild(selectedTr);
selectedTr = null;
}
}
}
function savestudent()
{
document.studentActionForm.operation.value = "save";
document.studentActionForm.submit();
}
function onClickedCell()
{
var clickedcell = event.srcElement;
if(selectedTr!=null)
{
setTrColor(selectedTr,"#FFFFFF");
}
while(clickedcell.tagName!="TR")
{
clickedcell = clickedcell.parentElement;
}
selectedTr = clickedcell;
setTrColor(selectedTr,"#FFDDFF");
}
</script>
</head>
<body bgcolor="#ffffff">
<br>
<hr height=1 />
<h2 align="center">
学生管理
</h2>
<html:form method="post" action="studentAction.do">
<html:hidden name="studentActionForm" property="deleteUID" />
<html:hidden name="studentActionForm" property="operation"/>
<table >
<tr>
<td class="tdframe">
<table class="table1">
<thead class="tdsectionbar">
<td align="center" class="tdsectionbar">学号</td>
<td align="center" class="tdsectionbar">姓名</td>
<td align="center" class="tdsectionbar" width="200">性别</td>
<td align="center" class="tdsectionbar" width="200">年龄</td>
<td align="center" class="tdsectionbar" width="200">班级</td>
</thead>
<tbody id="studentRows" onclick="onClickedCell()">
<logic:iterate name="studentActionForm" property="students" id="students">
<tr class="tdsectionbar">
<td class="tdbg0">
<html:text indexed="true" name="students" property="studentCode" />
<html:hidden indexed="true" name="students" property="studentUID" />
</td>
<td class="tdbg0">
<html:text indexed="true" name="students" property="studentName" />
</td>
<td class="tdbg0" align="center">
<html:text indexed="true" name="students" property="studentGender" />
</td>
<td class="tdbg0" align="center">
<html:text indexed="true" name="students" property="studentAge" />
</td>
<td class="tdbg0" align="center">
<html:text indexed="true" name="students" property="studentClass" />
</td>
<tr>
</logic:iterate>
</tbody>
</table>
</td>
</tr>
</table>
<br><br>
<input type="button" value="添加学生" class="button" onclick="addstudent();"/>
<input type="button" value="删除学生" class="button" onclick="deletestudent();"/>
<input type="button" value="保存学生" class="button" onclick="savestudent();"/>
</html:form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -