多級下拉菜單的級連顯示問題
多級下拉菜單的級連顯示問題。
在這里,我為了實現公司-部門級連顯示問題,我編寫了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" "
<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"> 當前位置:系統管理>>領導設置>>添加領導權限 </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="保存"> <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="
xmlns:xsi="
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
posted on 2008-10-14 09:41 小卓 閱讀(275) 評論(0) 編輯 收藏 所屬分類: html and js