日期:2011-01-08  浏览次数:20563 次

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

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