⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 newold.jsp

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@page import="java.util.*,java.text.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id='db' scope='request' class='Base.DataBean.DefaultDataBean' />
<%
	int collegesize = db.getCount("college");
	String []collegename = new String[collegesize];
	String []collegeid = new String[collegesize];
	for(int i=0;i<collegesize;i++){
		collegename[i] = db.getAttributeStr("college.name",i);
		collegeid[i] = db.getAttributeStr("college.id",i);
	}

	int groupsize = db.getCount("group");
	String []groupname = new String[groupsize];
	String []groupid = new String[groupsize];
	for(int i=0;i<groupsize;i++){
		groupname[i] = db.getAttributeStr("group.name",i);
		groupid[i] = db.getAttributeStr("group.id",i);
	}

	int departmentsize = db.getCount("department");
	String []departmentname = new String[departmentsize];
	String []departmentid = new String[departmentsize];
	for(int i=0;i<departmentsize;i++){
		departmentname[i] = db.getAttributeStr("department.name",i);
		departmentid[i] = db.getAttributeStr("department.id",i);
	}
	
	com.util.DealString ds = new com.util.DealString();
	com.db.CommonBean myBean = new com.db.CommonBean();
%>
<html>
<head>
<link rel=stylesheet href="../index.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>用户配置</title>
  <script language="javascript">
	  var collegesize = <%=collegesize%>;
	  groupname = new Array(collegesize);
	  groupid = new Array(collegesize);
	  for(var i=0;i<collegesize;i++){
		groupname[i] = new Array();
		groupid[i] = new Array();
	  }
	  departmentname = new Array(collegesize);
	  departmentid = new Array(collegesize);
	  for(var i=0;i<collegesize;i++){
		departmentname[i] = new Array();
		departmentid[i] = new Array();
	  }
	  <%

	  for(int i=0;i<collegesize;i++){

		String sql = "select * from kjc_group where college="+collegeid[i]+"";
		Vector vectgroup = (Vector)myBean.getDataBySql(sql);
		for(int j=0;j<vectgroup.size();j++){
			Hashtable hashgroup = (Hashtable)vectgroup.get(j);
			%>
				groupname[<%=i%>][<%=j%>] = "<%=ds.toString((String)hashgroup.get("name"))%>";
				groupid[<%=i%>][<%=j%>] = <%=ds.toString((String)hashgroup.get("id"))%>;
			<%
		}

		sql = "select * from kjc_department where college="+collegeid[i]+"";
		Vector vectdepartment = (Vector)myBean.getDataBySql(sql);
		for(int j=0;j<vectdepartment.size();j++){
			Hashtable hashdepartment = (Hashtable)vectdepartment.get(j);
			%>
				departmentname[<%=i%>][<%=j%>] = "<%=ds.toString((String)hashdepartment.get("name"))%>";
				departmentid[<%=i%>][<%=j%>] = <%=ds.toString((String)hashdepartment.get("id"))%>;
			<%
		}
	  }
	  %>
	  function gochange(){
		var tempindex = document.form1.college.options.selectedIndex-1;
		var tempgroup=document.form1.group;
		var tempdepartment=document.form1.department;
		clearList(tempgroup);
		clearList(tempdepartment);
		//var size = groupid[tempindex].length;
		alert(groupid[tempindex].length);
		for(int i=0;i<size;i++){
			tempgroup.options[0]=new Option("dfdf",23);
		}
	  }
		function clearList(ctrl){
			if (document.all) {
			  for(;ctrl.options.length>0;)
				ctrl.options.remove(ctrl.options.length-1);
			}else{
				for(;ctrl.options.length>0;)
					ctrl.options[ctrl.options.length-1] = null;
			}
		}

	  function go()
	  {
		 if(document.all.name.value==""
			||document.all.workid.value==""
			||document.all.password.value=="")
		  {
				alert("姓名、工号、密码必填!");
		  }
		  else if(document.all.college[document.all.college.selectedIndex].value=="0"
			||document.all.group[document.all.group.selectedIndex].value=="0"
			||document.all.department[document.all.department.selectedIndex].value=="0")
		  {
				alert("请检查学院、梯队、科室是否选择,为必填项!");
		  }
		  else
		  {
			  document.all.form1.action="add.cgi";
			  document.all.form1.submit();
		  }
	  }
  </script>
</head>

<body>
      <td>&nbsp;</td>
<form name="form1" method="post" action="add.cgi">
  <table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
    <tr>
    </tr>
  </table>
  <table width="100%"  border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="40">&nbsp;</td>
      <td width="910"><table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="20" class="title_s"><img src="../pics/login.gif" width=50>&nbsp;欢迎您>><%=(String)session.getAttribute("NAME")%> </td>
          </tr>
          <tr>
            <td height="5" bgcolor="#C8F8BA"></td>
          </tr>
          <tr>
            <td height="1" bgcolor="#2E990F"></td>
          </tr>
      </table></td>
      <td width="50">&nbsp;</td>
    </tr>
  </table>
  <table width="100%"  border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="40">&nbsp;</td>
      <td width="910">
        <table class="main_w" width="100%"  border="1" cellpadding="4" cellspacing="0" bordercolor="FFFFFF" bgcolor="E8FCE2">
          <tr bgcolor="#FFFFFF" class="title_s">
            <td height="20" colspan="2"><div align="center">添加用户</div>
                <div align="center"></div></td>
          </tr>
          <tr class="title_s">
            <td width="45%" height="20"><div align="center" class="title_s">
                <div align="center">用户姓名:</div>
            </div></td>
            <td width="55%" height="20" class="main_w">
              <div align="left">
                <input name="name" type="text" id="name">
            *</div></td>
          </tr>
          <tr>
            <td height="20" class="title_s"><div align="center" class="title_s">学号:</div></td>
            <td height="20"><div align="center" class="title_s">
                <div align="left">
                  <input name="workid" type="text" id="workid">
                *</div>
            </div></td>
          </tr>
          <tr>
            <td height="20" class="title_s"><div align="center">密&nbsp;&nbsp;&nbsp; 码:</div></td>
            <td height="20">              <div align="left">
                <input name="password" type="password" id="password">
                <span class="title_s">*</span></div></td>
          </tr>
          <tr>
            <td height="20" class="title_s"><div align="center">用户角色:</div></td>
            <td height="20"><select name="role">
							  			   <%
	for(int i=0;i<db.getCount("role");i++){
	%>
                <option value=<%= db.getAttributeStr("role.id",i) %> selected><%= db.getAttributeStr("role.name",i) %></option>
                <%
	  }
	  %>
            </select></td>
          </tr>
          <tr>
            <td height="20" class="title_s"><div align="center">性 &nbsp;&nbsp;&nbsp;别:</div></td>
            <td height="20">
              <div align="left">
                  <select name="sex" id="sex">
                    <option value="3" selected>请选择</option>
                    <option value="1">男</option>
                    <option value="0">女</option>
                  </select>
              </div></td></tr>
          <tr>
            <td height="20" class="title_s"><div align="center">民&nbsp;&nbsp;&nbsp; 族:</div></td>
            <td height="20">
              <div align="left">
                <input name="nation" type="text" id="nation">
              </div></td></tr>
          <tr>

⌨️ 快捷键说明

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