editzs.jsp

来自「--- --^_^-------------- 广师公寓中心 1.请装上」· JSP 代码 · 共 321 行

JSP
321
字号
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page language="java" import="java.sql.*" %>
<%
int counter=0;
Cookie cookies[]=request.getCookies();
if(cookies!=null){
   for(int i=0;i<cookies.length;i++){
       if(cookies[i].getName().equals("counter"))
	       counter=Integer.parseInt(cookies[i].getValue());
		  }
}
%> 
<%
if(session.getAttribute("login")== null)
  {%>
  <jsp:forward page="login1.jsp"/>
  <%}
%>
  <%!
String sql="";
String key="";
String type="";
%>
  <%
request.setCharacterEncoding("gb2312");
sql="SELECT * FROM student  where name='fdsfewrdfasdfdf' ";
key=request.getParameter("m_key");
type=request.getParameter("m_type");
%>
<html>
<head>
<title>宿舍查询&gt;编辑学生</title>
<style type="text/css">
<!--
table {
	font-family: "宋体";
	font-size: 14px;
	color: #000000;
}
.unnamed1 {
	border-bottom-width: 1px;
	border-bottom-style: dashed;
	border-bottom-color: #333333;
	border-top-width: 1px;
	border-top-style: dashed;
	border-top-color: #000099;
}
.unnamed2 {
	border-left-width: 1px;
	border-left-style: dashed;
	border-left-color: #000000;
}
.style1 {
	font-family: "隶书";
	font-size: 18px;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/background.gif">
<!-- ImageReady Slices (glry) -->
<table id="__01" width="680" height="425" border="0" cellpadding="0" cellspacing="0" align="center" background="images/glry_11.gif">
<!--DWLayoutTable-->
<tr>
  <td height="55" colspan="6"> <img src="images/glry_01.gif" width="680" height="55" alt=""></td>
</tr>
<tr>
  <td height="46" colspan="6"> <img src="images/glry_02.gif" width="680" height="46" alt=""></td>
</tr>
<tr>
  <td height="41" colspan="6"> <img src="images/glry_03.gif" width="680" height="41" alt=""></td>
</tr>
<tr>
  <td colspan="6" background="images/glry_04.gif" height="20" alt=""> <font color="#FF0000" size="2">
      <jsp:include page="time.htm"/>
<%
    if(counter==0){
 //if(session.getAttribute("counter1") == null){
    out.print("欢迎首次光临!");
	}
else{
    out.print("今天您已经光临了"+counter+"次!");
	//out.print("您已经光临了"+session.getAttribute("counter1")+"次!");
    }
%>
</font>
</td>
</tr>
<tr>
  <td width="115" height="19"><a href="gongyu.jsp"><img src="images/glry_05.gif" alt="" width="115" height="19" border="0"></a></td>
  <td width="113"><a href="ry.jsp"><img src="images/glry_06.gif" alt="" width="113" height="19" border="0"></a></td>
  <td width="112"><a href="xszs.jsp"><img src="images/glry_07.gif" alt="" width="112" height="19" border="0"></a></td>
  <td width="113"><a href="wh.jsp"><img src="images/glry_08.gif" alt="" width="113" height="19" border="0"></a></td>
  <td width="113"><a href="lx.jsp"><img src="images/glry_09.gif" alt="" width="113" height="19" border="0"></a></td>
  <td width="114"><a href="hd.jsp"><img src="images/glry_10.gif" alt="" width="114" height="19" border="0"></a></td>
</tr>
<tr>
  <td height="20" colspan="6" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="unnamed1">
      <!--DWLayoutTable-->
      <tr>
        <td width="556" height="20" valign="top"><a href="gongyu.jsp">首页</a>>>宿舍查询&gt;编辑学生</td>
        <td width="124" valign="top"><a href="zhexiao.jsp">注销<%=session.getAttribute("username")%></a></td>
      </tr>
  </table></td>
</tr>
<tr>
  <td height="167" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="113" height="7"></td>
      </tr>
      <tr>
        <td height="22" valign="top"><a href="hd1.jsp"><img src="images/glry_06.gif" alt="" width="113" height="19" border="0"></a></td>
      </tr>
      <tr>
        <td height="11"></td>
      </tr>
      <tr>
        <td height="20" valign="top"><a href="zs.jsp"><img src="images/glry_07.gif" alt="" width="112" height="19" border="0"></a></td>
      </tr>
      <tr>
        <td height="11"></td>
      </tr>
      <tr>
        <td height="23" valign="top"><a href="hd3.jsp"><img src="images/glry_08.gif" alt="" width="113" height="19" border="0"></a></td>
      </tr>
      <tr>
        <td height="9"></td>
      </tr>
      <tr>
        <td height="23" valign="top"><a href="hd4.jsp"><img src="images/glry_09.gif" alt="" width="113" height="19" border="0"></a></td>
      </tr>
      <tr>
        <td height="9"></td>
      </tr>
      <tr>
        <td height="23" valign="top"><a href="hd6.jsp"><img src="images/glry_13.gif" alt="" width="113" height="19" border="0"></a></td>
      </tr>
      <tr>
        <td height="9"></td>
      </tr>
  </table></td>
  <td colspan="5" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="unnamed2">
      <!--DWLayoutTable-->
      <tr>
        <td width="564" height="14">&nbsp;</td>
      </tr>
      <tr>
        <td height="43" valign="top"><div align="center">
            <form action="zs.jsp" method="post">
              <div align="left">&nbsp;&nbsp;查询关键字:
                  <input type="text" name="m_key" width="75">
                  请选择查找操作字段:
                  <select name="m_type">
                    <option value="xuehao">学号</option>
                    <option value="name">姓名</option>
                    <option value="age">年龄</option>
                    <option value="sex">性别</option>
                    <option value="zhuanye">专业</option>
                    <option value="build">哪栋</option>
                    <option value="sushe">宿舍</option>
                  </select>
                  <input type="image" src="images/chakan.gif">
              </div>
            </form>
        </div></td>
      </tr>
      <tr>
        <%
try{  
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{  
out.print(e);
}
try{  
String strDirPath=application.getRealPath(request.getRequestURI());   
strDirPath=strDirPath.substring(0,strDirPath.lastIndexOf('\\'))+"\\";  
strDirPath=application.getRealPath("ODBC/gongyu.mdb");   
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+strDirPath;  
Connection conn = DriverManager.getConnection(url);  
Statement stmt = conn.createStatement();
request.setCharacterEncoding("gb2312");
String sql="SELECT * FROM student where id="+request.getParameter("edit");
ResultSet rs = stmt.executeQuery(sql); 
int id=1; 
int xuehao=0;
String name="";
int age=0;
String sex="";
String zhuanye="";
String build="";
int sushe=0;  
while(rs.next()){
id=rs.getInt("id");
xuehao=rs.getInt("xuehao");
name=rs.getString("name");
age=rs.getInt("age");
sex=rs.getString("sex");
zhuanye=rs.getString("zhuanye");
build=rs.getString("build");
sushe=rs.getInt("sushe");
%>
        <td height="112" valign="top">
		<script language="JavaScript">
				    function MyCheck()
                {	                		
                    var textfield1 = form1.textfield1.value;
		            var textfield2 = form1.textfield2.value;
          var textfield3 = form1.textfield3.value;
					var textfield = form1.textfield.value;
                    var textfield4 = form1.textfield4.value;
		            var textfield5 = form1.textfield5.value;
		            var textfield6 = form1.textfield6.value;
								
                    if(textfield1==null||textfield1=="")
                    {
                        alert("学号不能为空!");
	                    return false;
                    }
					if(isNaN(textfield1))return (textfield1=''),alert('学号只能输入数字!'),false;
                    if(textfield2==null||textfield2=="")
                    {
                        alert("姓名不能为空!");
	                    return false;
                    }					
                    if( textfield2.indexOf("<") >=0 || textfield2.indexOf(">") >=0 )
                    {
	                    alert("姓名含有非法字符!");
	                    return false;
                    }
                    
                    if(textfield3==null||textfield3=="")
                    {
                        alert("年龄不能为空!");
	                    return false;
                    }
					if(isNaN(textfield3))return (textfield3=''),alert('年龄只能输入数字!'),false;
                    if(textfield==null||textfield =="")
                    {
                        alert("性别不能为空!");
	                    return false;
                    }					
                    if(textfield4==null||textfield4=="")
                    {
                        alert("专业不能为空!");
	                    return false;
                    }
                    if(textfield5==null||textfield5=="")
                    {
	                    alert("楼栋不能为空!");
	                    return false;
                    }
                    
                    if(textfield6==null||textfield6=="")
                    {
                        alert("宿舍不能为空!");
	                    return false;
                    }
             		if(isNaN(textfield6))return (textfield6=''),alert('宿舍只能输入数字!'),false;
                    return true;
                }
		
		</script>
            <form name="form1" method="post" action="editzs1.jsp" id="form1" onSubmit="return MyCheck();">
              <input value=<%=id%> type="hidden" name="id">
              <table width="100%" border="1" cellpadding="0" cellspacing="0">
                <!--DWLayoutTable-->
                <tr>
                  <td width="564" height="112"><div align="left">
                      <p>               <span class="style1">正在编辑<font color="#FF0000"><%=name%></font>学生</span></p>
                      <p> 学号:
                          <input name="textfield1" type="text" id="textfield1" size="13" value=<%=xuehao%>>
                          姓名:
                          <input name="textfield2" type="text" size="13" value=<%=name%>>
                            年龄:
                          <input name="textfield3" type="text" size="5" value=<%=age%>>
                          性别:
                          <input name="textfield" type="text" value=<%=sex%> size="5">
                      </p>
                      <p> 专业:
                          <input name="textfield4" type="text" id="textfield4" value=<%=zhuanye%>>
                          哪栋:
                          <input name="textfield5" type="text" id="textfield5" size="10" value=<%=build%>>
                          宿舍:
                          <input name="textfield6" type="text" id="textfield6" size="10" value=<%=sushe%>>
                      </p>
                      <p>          
                          <input name="Submit1" type="submit" id="Submit1" value="编辑">
                              
                          <input type="reset" name="Submit2" value="重置">
                              
                          <input type="button" name="Submit3" value="返回" onClick="javascript:history.back();">
                      </p>
                  </div></td>
                </tr>
              </table>
          </form></td>
        <%}  
rs.close();  
stmt.close();  
conn.close();
}
catch(Exception ex)
{  
out.print(ex);
}
%>
      </tr>
  </table></td>
</tr>
<tr>
  <td height="48" colspan="6"><img src="images/glry_12.gif" width="680" height="48" alt=""></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?