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

📄 stepmemright.jsp

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JSP
字号:
<%@page language="java" contentType="text/html;charset=GBK"%>
<%@page import="java.util.*,java.text.*,com.util.DealString,java.util.Hashtable"%>


<jsp:useBean id="myBean" scope="page" class="com.db.ParentBean"/>

<%
	DealString ds = new DealString();
	String type = ds.toString(request.getParameter("type"));
	String id = ds.toString(request.getParameter("id"));
	String first = ds.toString(request.getParameter("first"));
	String select2id[] = ds.splitStr(ds.toGBK(request.getParameter("select2id")),',');
	String select2name[] = ds.splitStr(ds.toGBK(request.getParameter("select2name")),',');

String count = ds.toString((String)request.getParameter("count"));
String showdepartment = (String)request.getParameter("showdepartment");
String txt_rybh = ds.toString((String)request.getParameter("txt_rybh"));
String txt_rymc = ds.toString((String)request.getParameter("txt_rymc"));

	String sql = "" ;
	if(type.equals("0"))sql="select a.id,a.name,b.name as college,c.name as department from kjc_people a,kjc_college b,kjc_department c where a.collegeid=b.id and a.departmentid=c.id order by a.name";
	else if(type.equals("1"))sql = "select a.id,a.name,b.name as college,c.name as department from kjc_people a,kjc_college b,kjc_department c where a.collegeid=b.id and a.departmentid=c.id and collegeid="+id+" order by a.name";
	else if(type.equals("2"))sql = "select a.id,a.name,b.name as college,c.name as department from kjc_people a,kjc_college b,kjc_department c where a.collegeid=b.id and a.departmentid=c.id and departmentid="+id+" order by a.name";
	Vector vect = new Vector ( ) ;
	if( !sql.equals("") ) vect = myBean.getDataBySql(sql);


%>
<html>
<head><title>选择人员</title>
<link href="js/main.css" type=text/css rel=stylesheet>
<script language="javascript" src="js/department.js"></script>
</head>
<body>
<script>


	  var count = "<%=count%>";
	  var txt_rybh = "<%=txt_rybh%>";
	  var txt_rymc = "<%=txt_rymc%>";
</script>


<table border="0" cellpadding="2" style="border-collapse: collapse; color:#FFFFFF" bordercolor="D0E7FF" width="100%" height="18" bgcolor="#007EAE">
	  <tr>
	    <td align="left" >&nbsp;<b>人员列表</b></td>
	  </tr>
</table>

<form method="POST" name="form1" action="stepMemRight.jsp">
<table width="100%" align="left" height="1" >
<tr>
  <td width="100%" align="center">
  <select size="8" name="select1" id="select1"  style="width: 200"  ondblclick="add()">
  <%
  for(int i=0;i<vect.size();i++)
  {
	  Hashtable hash = (Hashtable)vect.get(i);
		String str1 = (String)hash.get("id");
		String str2 = (String)hash.get("name");
		String str3 = (String)hash.get("college");
		String str4 = (String)hash.get("department");
	  %>
  <option value="<%=str1%>"><%=str2%> [<%=str3%>\<%=str4%>]</option>
  <%}%>
  </select>
  </td>
</tr>
<tr>
  <td width="100%" align="center">
  <img src="js/jt01.gif" onclick="del()" title="删除" style="cursor:hand;">
  <img src="js/jt02.gif" onclick="add()" title="添加" style="cursor:hand;">
  <img src="js/jt03.gif" onclick="delall()" title="删除所有" style="cursor:hand;">
  <img src="js/jt04.gif" onclick="addall()" title="添加所有" style="cursor:hand;">
  </td>
</tr>
<tr>
  <td width="100%" align="center">
  <select size="8" name="select2" id="select2" style="width: 200"  ondblclick="del()">   
  <%for(int i=1;i<select2id.length;i++){%>
  <option value="<%=select2id[i]%>"><%=select2name[i]%></option>
  <%}%>
  <%

  if(first.equals("first"))
  {%>
  <script>
  var ids = "";
  var name = "";

if(txt_rybh!=null&txt_rybh!="")
{
	name = parent.window.opener.document.getElementById(txt_rymc).value ;
	ids = parent.window.opener.document.getElementById(txt_rybh).value ;
}
else
{
	name = window.parent.opener.document.all.txt_rymc.value;
	ids = window.parent.opener.document.all.txt_rybh.value;
}
  var tids = ids.split(",");
  var tname = name.split(",");
  for(var i=0;i<tids.length;i++)
  {
	if(tname[i]=="")continue;
	document.write("<option value='"+tids[i]+"'>"+tname[i]+"</option>");
  }
  </script>
  <%}%>
  </select>
  </td>
</tr>
<tr>
  <td width="100%" align="center"><br>
  <input type="button" value="确定" name="Button_OK" onclick="transfer()">
  <input type="button" value="取消" name="Button_OK2" onclick="window.parent.close();">
  </td>
</tr>
</table>
</form>
<script language="javascript">

function transfer(){

		var right = document.all.select2;
		var ids = "";
		var name = "";

		if(count!=null&&count!=""&&count<right.length)
			alert("只能选"+count+"人,请先删除到规定数目!");
		else
		{

			for(var i=0;i<right.length;i++)
			{
				if(ids!="")
				{
					ids = ids + ',' ;
					name = name + ',' ;
				}
				ids = ids + right.options[i].value;
				
				//判断是否去掉单位
				var showdepartment = "<%=showdepartment%>";
				var onename = right.options[i].text;
				if(showdepartment=="1")
				{
					onename = onename.substring(0,onename.indexOf("[")-1);
				}
				name = name + onename;
			}
			if(txt_rybh!=null&txt_rybh!="")
			{
				parent.window.opener.document.getElementById(txt_rymc).value = name ;
				parent.window.opener.document.getElementById(txt_rybh).value = ids ;
			}
			else
			{
				parent.window.opener.document.all.txt_rymc.value = name;
				parent.window.opener.document.all.txt_rybh.value = ids;
			}
			parent.window.opener.focus();
			parent.window.close();
		}


}
</script>


</body>




</html>





<%
myBean.closeConn();
%>

⌨️ 快捷键说明

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