呵呵,刚说去干活,突然发现被点名,哈LZ 说的是 Select 自动展开吧,可以实现请参考下贴中俺最后一贴代码【高难?】keyCode的操作。 
http://community.csdn.net/Expert/topic/5542/5542762.xml?temp=.8346063干活去了,哈

解决方案 »

  1.   

    这是你上次的代码,我就怎么都加不成功让菜单展开
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
    <head>
      <title> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
    </head>
    <SCRIPT LANGUAGE="JavaScript"> 
    <!-- 
    function Dsy() 

        this.Items = {};
        this.Provinces = new Array();
        this.Cities = new Array();
        this.Counties = new Array();

    Dsy.prototype.add = function(id,iArray) 

        this.Items[id] = iArray; 

    Dsy.prototype.Exists = function(id) 

        if(typeof(this.Items[id]) == "undefined") return false; 
        return true; 

    function change(v)

        var str = "0"; 
        for(i=0;i<v;i++)
        {
            var oSelect = document.getElementById(s[i]);
            str += "_"+(oSelect.options[oSelect.selectedIndex].value);
        }
        var ss=document.getElementById(s[v]);    with(ss)
        {
            length = 0; 
            options[0]=new Option(opt0[v],opt0[v]);
            if(v && document.getElementById(s[v-1]).selectedIndex>0 || !v) 
            {
                if(dsy.Exists(str))
                { 
                    ar = dsy.Items[str];
                    var strLevelName;
                    switch (str.split("_").length)
                    {
                        case 1:
                            strLevelName = "Provinces";
                            break;
                        case 2:
                            strLevelName = "Cities";
                            break;
                        case 3:
                            strLevelName = "Counties";
                            break;
                    }
                    for(i=0; i<ar.length; i++)
                    {
                        dsy[strLevelName][i] = ar[i].split(".");
                        options[length]=new Option(dsy[strLevelName][i][1],i);
                    }                if(v)options[1].selected = true; 
                }
            }
            if(++v<s.length){change(v);} 
        } 
    }var dsy = new Dsy(); dsy.add("0",["b.北京","a.安徽","f.福建"]); dsy.add("0_0",["b.北京"]); 
    dsy.add("0_0_0",["b.北京市","d.东城","x.西城","c.崇文","x.宣武","c.朝阳","f.丰台","s.石景山","h.海淀","m.门头沟","f.房山","t.通州","s.顺义","c.昌平","d.大兴","p.平谷","h.怀柔","m.密云","y.延庆"]); dsy.add("0_1",["a.安庆","b.蚌埠","c.巢湖","c.池州","x.滁州","f.阜阳","h.合肥","h.淮北","h.淮南","h.黄山","l.六安","m.马鞍山","s.宿州","t.铜陵","w.芜湖","x.宣城","h.亳州"]); 
    dsy.add("0_1_0",["a.安庆市","h.怀宁县","q.潜山县","s.宿松县","t.太湖县","t.桐城市","w.望江县","y.岳西县","z.枞阳县"]); 
    dsy.add("0_1_16",["x.利辛县","m.蒙城县","w.涡阳县","h.亳州市"]); dsy.add("0_2",["f.福州","l.龙岩","n.南平","n.宁德","p.莆田","q.泉州","s.三明","x.厦门","z.漳州"]); 
    dsy.add("0_2_0",["c.长乐市","f.福清市","f.福州市","l.连江县","l.罗源县","m.闽侯县","m.闽清县","p.平潭县","y.永泰县"]); 
    dsy.add("0_2_5",["a.安溪县","d.德化县","h.惠安县","j.金门县","j.晋江市","n.南安市","q.泉州市","s.石狮市","y.永春县"]); dsy.add("0_29_8",["苍南县","洞头县","乐清市","平阳县","瑞安市","泰顺县","温州市","文成县","永嘉县"]); 
    dsy.add("0_29_9",["舟山市","岱山县","嵊泗县"]); 
    dsy.add("0_30",["重庆"]); 
    dsy.add("0_30_0",["城口县","大足县"]); 
    //--> 
    </SCRIPT> 
    <SCRIPT LANGUAGE = JavaScript> 
    var s = ["s1","s2","s3"]; 
    var opt0 = ["省份","地级市","市、县级市、县"]; 
    function setup() 

        for(i=0;i<s.length;i++)
        {
            if (i<s.length-1)
            {
                document.getElementById(s[i]).onchange = new Function("change("+(i+1)+")");
            }
            
            document.getElementById(s[i]).onmouseover = function ()
            {
                this.focus();
            };
            document.getElementById(s[i]).onkeypress = function ()
            {
                this.selectedIndex = 0;
                var strInitial = String.fromCharCode(event.keyCode).toLowerCase();
                this.options.length = 1;
                var numIndex = parseInt(this.id.substr(1,1));            var strLevelName;
                switch (numIndex)
                {
                    case 1:
                        strLevelName = "Provinces";
                        break;
                    case 2:
                        strLevelName = "Cities";
                        break;
                    case 3:
                        strLevelName = "Counties";
                        break;
                }            var arrCurrent = dsy[strLevelName];
                for (var i=0; i<arrCurrent.length; i++)
                {
                    if (arrCurrent[i][0] === strInitial)
                    {
                        this.options.add(new Option(arrCurrent[i][1],i));
                    }
                }
                if (numIndex<3 && this.options.length>1)
                {
                    this.selectedIndex = 1;
                    change(numIndex);
                }        };
        }    change(0); 

    //--> 
    </SCRIPT> 
    </head> 
    <body bgcolor="#E0E0E0" onLoad="setup()"> 
    多级关联菜单: 
    <form name="frm"> 
    <p> 
    起点城市 
    <select id="s1"> 
    <option>省份</option> 
    </select> 
    <select id="s2"> 
    <option>地级市</option> 
    </select> 
    <select id="s3"> 
    <option>市、县级市、县</option> 
    </select> 
    </p> 
    </form> 
    </body> 
    </html>
      

  2.   

    晕,俺那个是用于静态 Select 的,动态的当然会有问题!需要动态初始化,LZ 自己改改吧!
      

  3.   

    动态的先从数据库中读,然后放入ls定义的数组?
    然后就不必选择每个select时候刷新访问数据库?