📄 addszhxx.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="Date.*,shujuku.*,java.util.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
request.setCharacterEncoding("gb2312");
String shenfen = (String)session.getAttribute("shenfen");
if(shenfen == null||shenfen.equals("admin") == false){
response.sendRedirect("../errer.jsp");
}
String action = (String)request.getParameter("action");
String id = (String)request.getParameter("id");
String name = (String)request.getParameter("name");
String password = (String)request.getParameter("password");
String sex = (String)request.getParameter("sexgroup");
String colleg = (String)request.getParameter("college");
String dep = (String)request.getParameter("dep1");
String clas = (String)request.getParameter("clas");
String major = (String)request.getParameter("major");
String yid = (String)request.getParameter("yid");
Data data = new Data();
if(id!=null&&action!=null&&action.equals("add")){
String sql = "insert into studentinfo(Stu_ID,Stu_password,Stu_name,Stu_sex,"+
"Stu_college_ID,Stu_dep_ID,Stu_class,Stu_major)values('"+id+"','"+password+"',"+
"'"+name+"','"+sex+"','"+colleg+"','"+dep+"','"+clas+"','"+major+"')";
if(data.addInof(sql))
{
out.print("<script>alert('添加成功!')</script>");
}else out.print("<script>alert('添加失败!')</script>");
}else if(id!=null&&action!=null&&action.equals("update")){
String sql = "update studentinfo set Stu_ID='"+id+"',Stu_password='"+password+"',"+
"Stu_name='"+name+"',Stu_sex='"+sex+"',Stu_college_ID='"+colleg+"',Stu_Dep_ID='"+dep+"',"+
"Stu_class='"+clas+"',Stu_major='"+major+"' where Stu_ID='"+yid+"'";
if(data.addInof(sql))
{
out.print("<script>alert('修改成功!')</script>");
}else out.print("<script>alert('修改失败!')</script>");
}
ArrayList<College> list = data.getCollegeAndDep();
%>
<link href="../css/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="usersForm" method="post" action="addszhxx.jsp?action=<%=action%>&&yid=<%=yid%>" onSubmit="return isok();">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF" >
<tr>
<td height="22" colspan="2" align="left" ><strong class="text13"><%=action%>学生信息</strong></td>
</tr>
<tr>
<td width="33%" height="22" align="center" >学生学号:</td>
<td width="67%" height="22" align="left" ><input name="id" type="text" class="input" id="id" maxlength="10">
<span class="text13">(*)10个字符以内</span></td>
</tr>
<tr>
<td height="22" align="center" >学生姓名:</td>
<td width="67%" height="22" align="left" ><input name="name" type="text" class="input" id="name" maxlength="10">
<span class="text13">(*) 10个字符以内</span></td>
</tr>
<tr>
<td width="33%" height="22" align="center" >登陆密码:</td>
<td height="22" align="left" ><input name="password" type="text" class="input" maxlength="20" >
<span class="text13">(*) 20个字符以内</span></td>
</tr>
<tr>
<td width="33%" height="22" align="center" >性别:</td>
<td height="22" align="left" ><p>
<label>
<input name="sexgroup" type="radio" value="男" checked>
男</label>
<label>
<input type="radio" name="sexgroup" value="女">
女</label>
<br>
</p></td>
</tr>
<tr>
<td height="1" align="center" >学生所在学院:</td>
<td height="1" align="left" class="text13"><select name="college" onChange="opchange(this.value)">
</select>
(*)</td>
</tr>
<tr>
<td height="1" align="center" >学生所在系别:</td>
<td height="1" align="left" class="text13"><select name="dep1">
</select>
(*)</td>
</tr>
<tr>
<td height="1" align="center" >班级:</td>
<td height="1" align="left" ><input name="clas" type="text" class="input" id="clas" size="40" maxlength="50" >
<span class="text13">(*) 50个字符以内</span></td>
</tr>
<tr>
<td height="1" align="center" >学生所在专业</td>
<td height="1" align="left" ><input name="major" type="text" class="input" id="major" size="40" maxlength="50" >
<span class="text13">(*) 50个字符以内</span></td>
</tr>
<tr>
<td height="15" colspan="2" align="center" ><input name="Submit" type="submit" class="button" value="提交">
<input name="Submit2" type="reset" class="button" value="重置"></td>
</tr>
</table>
</form>
</body>
</html>
<script language="javascript">
var text = new Array(<%=list.size()%>);
for(var i=0;i<<%=list.size()%>;i++){
text[i] = new Array();
text[i].length=0;
}
var value = new Array(<%=list.size()%>);
for(var i=0;i<<%=list.size()%>;i++){
value[i] = new Array();
value[i].length=0;
}
<%
College college = null;
for(int i=0;i<list.size();i++){
college = list.get(i);%>
var oOption = document.createElement("OPTION");
oOption.value="<%=college.getCollege_ID()%>";
oOption.text="<%=college.getCollege_name()%>";
usersForm.college.add(oOption);
<%
for(int j=0;j<college.getDepList().size();j++)
{
%>
text[<%=i%>].length++;
text[<%=i%>][text[<%=i%>].length-1]="<%=college.getDepList().get(j).getDep_name()%>";
value[<%=i%>].length++;
value[<%=i%>][value[<%=i%>].length-1]="<%=college.getDepList().get(j).getDep_ID()%>";
<%
}
}
%>
opchange(1);
function opchange(id)
{
usersForm.dep1.length=0;
for(var i=0;i<text[id-1].length;i++)
{
var oOption = document.createElement("OPTION");
oOption.value=value[id-1][i];
oOption.text=text[id-1][i];
usersForm.dep1.add(oOption);
}
}
function isok(){
var str=document.usersForm.id.value;
if(str==""){
alert("学号不能为空!");
document.usersForm.id.focus();
return false;
}
var str2=document.usersForm.name.value;
if(str2==""){
alert("密码不能为空!");
document.usersForm.name.focus();
return false;
}
var str3 = document.usersForm.password.value;
if(str3==""){
alert("登陆密码不能为空!");
document.usersForm.password.focus();
return false;
}
var str4 = document.usersForm.clas.value;
if(str4==""){
alert("班级不能为空!");
document.usersForm.clas.focus();
return false;
}
var str5 = document.usersForm.major.value;
if(str5==""){
alsert("专业不能为空!");
document.userForm.major.focus();
return false;
}
}
</script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -