Go homepage(回首页)
Upload pictures (上传图片)
Write articles (发文字帖)

The author:(作者)aaa
published in(发表于) 2013/12/15 8:42:05
ASP.NET:多级下拉菜单的级连显示问题_.net资料_编程技术

ASP.NET:多级下拉菜单的级连显示问题_.net资料_编程技术-你的首页-uuhomepage.com





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




在这里,我为了实现公司-部门级连显示问题,我编写了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.*" %>




http://www.w3.org/TR/html4/loose.dtd">










添加领导权限




























<%




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




session.setAttribute("EmployUserID",strUserID);




%>
















&nbsp;&nbsp;当前位置:系统管理&gt;&gt;领导设置&gt;&gt;添加领导权限




























公司:
















部门:













&nbsp;&nbsp;&nbsp;&nbsp;
















<%




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%>










Web.xml代码如下:










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">







selectCropDepart




pub.SelectCropDepartServlet










selectCropDepart




/selectCropDepart













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.




*




* 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 ="";




String xml_end = "";




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+= "" ;




int i=0;




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




while (i


xml+= "";




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 {




}




}











If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)





QQ:154298438
QQ:417480759