国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET:多級下拉菜單的級連顯示問題

2024-07-10 13:08:45
字體:
來源:轉載
供稿:網友
,歡迎訪問網頁設計愛好者web開發。

多級下拉菜單的級連顯示問題。

在這里,我為了實現公司-部門級連顯示問題,我編寫了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" value="保存">&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="button" value="關閉" onclick="window.close();" > </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 {

       }

}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 浠水县| 阳朔县| 丹棱县| 义乌市| 兴山县| 丰县| 和平区| 资中县| 邢台市| 肃北| 屏边| 稷山县| 阿城市| 定南县| 监利县| 淳化县| 银川市| 台江县| 永城市| 民和| 壶关县| 鱼台县| 西城区| 滕州市| 美姑县| 宁蒗| 吴桥县| 安丘市| 宜春市| 铁岭县| 安国市| 黎城县| 江津市| 百色市| 托克逊县| 若羌县| 嵊泗县| 孟津县| 平昌县| 宝鸡市| 平武县|