| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 985 人关注过本帖
标题:在网上下了个三级的联动菜单,一个页面只能用一次,用二次就不行
取消只看楼主 加入收藏
chinasj
Rank: 2
等 级:论坛游民
威 望:1
帖 子:62
专家分:74
注 册:2008-4-26
结帖率:0
收藏
 问题点数:0 回复次数:1 
在网上下了个三级的联动菜单,一个页面只能用一次,用二次就不行
function Dsy(){
this.Items = {};
}
    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++){ str+=("_"+(document.getElementById(s[i]).selectedIndex-1));};
        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];
            for(i=0;i<ar.length;i++)options[length]=new Option(ar[i],ar[i]);
            if(v)options[1].selected = true;
        }
        }
        if(++v<s.length){change(v);}
        }
}
var dsy = new Dsy();
<%
sub province() '省份
    dim rsa,pro,i
    set rsa = conn.execute("select * from Chinasj_Province order by px asc,id asc")
    If not Rsa.Eof then
    i = 1
    do while not rsa.eof
        pro = pro & (""""&Rsa("Province")&""",")
        Call city(rsa("ProvinceID"),Cstr(i)-1)
    i = i + 1    
    rsa.movenext
    loop
        Response.Write ("dsy.add(""0"",[")
        Response.Write mid(pro,1,len(pro)-1)
        Response.Write ("]);")&vbcrlf
    End If
end sub
sub city(provinceID,pid) '市
    dim rsb,cit,i
    set rsb = conn.execute("select * from Chinasj_city where father='"&provinceID&"' order by px asc,id asc")
    If not rsb.Eof then
    i = 1
    do while not rsb.eof
        cit = cit & (""""&rsb("city")&""",")
        Call area(rsb("cityid"),pid,i-1) '
    i = i + 1    
    rsb.movenext
    loop
        Response.Write ("dsy.add(""0_"&pid&""",[")
        Response.Write mid(cit,1,len(cit)-1)
        Response.Write ("]);")&vbcrlf
    End If
end sub
sub area(cityid,pid,cid) '县
    dim rsc,ara
    set rsc = conn.execute("select * from Chinasj_area where father='"&cityid&"' order by px asc,id asc")
    If not rsc.Eof then
    do while not rsc.eof
        ara = ara & (""""&rsc("area")&""",")
    rsc.movenext
    loop
        Response.Write ("dsy.add(""0_"&pid&"_"&cid&""",[")
        Response.Write mid(ara,1,len(ara)-1)
        Response.Write ("]);")&vbcrlf
    End If
end sub
%>
<% call province()%>

var s=["s1","s2","s3"];
var opt0 = ["省份...","地级市...","市、县级市、县..."];
function setup()
{
 for(i=0;i<s.length-1;i++)
  document.getElementById(s[i]).onchange=new Function("change("+(i+1)+")");
 change(0);
}因为我要同一个页面中用三处,不知道怎么弄?感激不尽!

[[it] 本帖最后由 chinasj 于 2008-4-26 22:08 编辑 [/it]]
搜索更多相关主题的帖子: 菜单 function prototype document 
2008-04-26 00:53
chinasj
Rank: 2
等 级:论坛游民
威 望:1
帖 子:62
专家分:74
注 册:2008-4-26
收藏
得分:0 
麻烦高手们帮忙解决一下,小妹感激不尽!
2008-04-26 01:35
快速回复:在网上下了个三级的联动菜单,一个页面只能用一次,用二次就不行
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050210 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved