分享
 
 
 

多级下拉菜单的级连显示问题

王朝other·作者佚名  2007-03-19
窄屏简体版  字體: |||超大  

多级下拉菜单的级连显示问题。

在这里,我为了实现公司-部门级连显示问题,我编写了leader_add_competence_dialogquery.jsp ,web.xml,SelectCropDepartServlet.java 类。

其中注意的是leader_add_competence_dialogquery中的.jspChange_Select() javascript函数中的/selectCropDepart是在web.xml中定义的servlet类。我们在实现应用当中需要修改的用红字标出。

其中leader_add_competence_dialogquery.jsp代码如下:

<%@ page contentType="text/html; charset=gbk" language="java" import="java.sql.*" errorPage="" %>

<%@ page import="pub.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>添加领导权限</title>

<link href="../css/putong.css" type="text/css" rel="stylesheet">

<base target="_self">

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">

<META HTTP-EQUIV="Expires" CONTENT="0">

</head>

<script language="javascript">

var req;

window.onload=function(){

}

function Change_Select(){

var zhi = document.getElementById('Corp').value;

var url = "../selectCropDepart?id=" + escape(zhi);

//alert(url);

if (window.XMLHttpRequest) {

req = new XMLHttpRequest();

}else if (window.ActiveXObject) {

req = new ActiveXObject("Microsoft.XMLHTTP");

}

if(req){

req.open("GET", url, true);

req.onreadystatechange = callback;

req.send(null);

}

}

function callback() {

if (req.readyState == 4) {

if (req.status == 200) {

parseMessage();

// update the HTML DOM based on whether or not message is valid

}else{

alert ("Not able to retrieve description" +req.status+req.statusText);

}

}

}

function parseMessage() {

var xmlDoc = req.responseXML.documentElement;

var xSel = xmlDoc.getElementsByTagName('select');

var select_root = document.getElementById('Depart');

select_root.options.length=0;

for(var i=0;i<xSel.length;i++)

{

var xValue = xSel[i].childNodes[0].firstChild.nodeValue;

var xText = xSel[i].childNodes[1].firstChild.nodeValue;

var option = new Option(xText,xValue);

try

{

select_root.add(option);

}

catch(e){

}

}

}

function AddLeaderCompetence(){

var key=document.all.HiddenKey.value; document.from1.action="leader_ctl.jsp?Oper=addCompetence&Key="+key;

document.from1.submit();

}

</script>

<body>

<%

String strUserID=request.getParameter("Key");

session.setAttribute("EmployUserID",strUserID);

%>

<form name="from1" action="leader_ctl.jsp" method="post">

<table cellSpacing="0" cellPadding="0" width="100%" bgColor="#bfcae6" border="0" background="../images/subtitle.gif">

<tr>

<td width="99%" height="26"><FONT face="宋体">

<DIV align="left"><FONT face="宋体" color="#ffffff">&nbsp;&nbsp;当前位置:系统管理&gt;&gt;领导设置&gt;&gt;添加领导权限 </FONT>

</DIV>

</FONT>

</td>

</tr>

</table>

<input type="hidden" name="HiddenKey" value="<%=strUserID%>" >

<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#AABDE0">

<tr bgcolor="#FFFFFF">

<td align="right">公司:</td>

<td>

<SELECT name="Corp" id="Corp" onChange="Change_Select()" >

<OPTION value="all" selected>所有公司</OPTION></SELECT></td>

</tr>

<tr bgcolor="#FFFFFF">

<td align="right">部门:</td>

<td><SELECT name="Depart" id="Depart">

<OPTION value="all" selected>所有部门</OPTION></SELECT></td>

</tr>

<tr bgcolor="#FFFFFF">

<td colspan="2" align="center"><input type="button" onClick="AddLeaderCompetence();" class="button" style="width:80px" value="保存">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="button" value="关闭" onClick="window.close();" style="width:80px"> </td>

</tr>

</table>

</form>

</body>

<%

Conn conn=new Conn();

String m1Script="";

//String m2Script="";

m1Script=PubClass.BindAllCorpList("document.all.Corp");

//m2Script=PubClass.BindAllDepartList("document.all.Depart",""+session.getAttribute("cropid"));

//sPositionList=conn.bindDropListSel("document.all.PositionName","select * from sys08_Position","PositionName","PositionID");

%>

<%= m1Script%>

</html>

Web.xml代码如下:

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4"

xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<servlet>

<servlet-name>selectCropDepart</servlet-name>

<servlet-class>pub.SelectCropDepartServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>selectCropDepart</servlet-name>

<url-pattern>/selectCropDepart</url-pattern>

</servlet-mapping>

</web-app>

SelectCropDepartServlet.java Servlet类代码如下

/**

* 从sys04_Machine表中取数据进行二级下拉菜单(公司,部门)及关联的servlet类

* @author 邓浩

*/

public class SelectCropDepartServlet extends HttpServlet {

public SelectCropDepartServlet() {

super();

}

public void destroy() {

super.destroy(); }

/**

* The doGet method of the servlet. <br>

*

* This method is called when a form has its tag value method equals to get.

*

* @param request the request send by the client to the server

* @param response the response send by the server to the client

* @throws ServletException if an error occurred

* @throws IOException if an error occurred

*/

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/xml");

response.setCharacterEncoding("UTF-8");

response.setHeader("Cache-Control", "no-cache");

String targetId = request.getParameter("id").toString();

String xml_start ="<selects>";

String xml_end = "</selects>";

String xml = "";

try{

Conn conn=new Conn();

DataTable dt=new DataTable();

String Sql="select * from sys04_Machine where cropid="+targetId;

////System.out.println("Sql:"+Sql);

xml+= "<select><value>all</value><text>所有部门</text></select>" ;

int i=0;

if (conn.querySql(Sql,dt)){

while (i<dt.getRowCount()){

xml+= "<select><value>"+dt.getItemForName(i,"MachID").toString()+"</value><text>"+dt.getItemForName(i,"MachName").toString()+"</text></select>";

i=i+1;

}

}

String last_xml = xml_start + xml + xml_end;

//System.out.println("last_xml:"+last_xml);

// last_xml = new String(last_xml.getBytes("UTF-8"), "GB2312");

response.getWriter().write(last_xml);

}// try

catch (Exception e){

System.out.print(e.getMessage());

}

}

public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{

doGet(request,response);

}

public void init() throws ServletException {

}

}

2006-08-18

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有