首页 | 站长免费中心 | 新手上路 | 网站运营 | 网页制作 | 图片设计 | 动画设计 | 网页编程 | 网页特效 | 本站专题 | 虚拟主机 | 域名注册 | 网站建设 | 程序下载
       免费空间资源 | 新闻咨询 | 免费域名 | 免费网盘 | 网站推广 | 网站策划 | 建站经验 | 网站优化 | 网页代码 | 源码下载 | 音乐小偷 | 网络赚钱 | 论坛交流
网站建设
网站建设
虚拟主机
虚拟主机
域名注册
域名注册
711网络首页
站长工具
站长工具
网站源码
网站源码
站长论坛
站长论坛

 711网络 网页编程ASP代码

无限级联下拉菜单代码

来源: 互联网    日期:2008-4-30
 
<script language="javascript">
//<!--
var arrArea=new Array(
[0,"中国大陆","10"],
[1,"湖北","1004"],
[2,"鄂州市","1005"],
[2,"恩施土家族苗族自治州","1006"],
[3,"巴东县","1007"],
[3,"恩施市","1008"],
[3,"鹤峰县","1009"],
[3,"建始县","1010"],
[3,"来凤县","1011"],
[3,"利川市","1012"],
[3,"咸丰县","1013"],
[3,"宣恩县","1014"],
[2,"黄冈","1015"],
.....
[2,"绥化","989"],
[3,"安达市","990"],
[3,"海伦市","991"],
[3,"兰西县","992"],
[3,"明水县","993"],
[3,"青冈县","994"],
[3,"庆安县","995"],
[3,"绥化市","996"],
[3,"绥棱县","997"],
[3,"望奎县","998"],
[3,"肇东市","999"]
);
/* ******************** ******************** ******************************** */
function getRoute(dic,value,mode){
var strRoute,intDepth=-1;
for(var i=dic.length-1;i>-1;i--){
if(intDepth>-1){
if(intDepth==0) return(strRoute);
if(dic[i][0]<intDepth){
strRoute=i+","+strRoute;
intDepth--;
}
}else{
if(dic[i][mode]==value){
strRoute=i.toString();
intDepth=dic[i][0];
}
}
}
return(strRoute);
}
function getRoutes(dic,route,mode){
var strRoute="",depth=0;
var arrRoute=route.split(",");
var intDepth=arrRoute.length-1;
for(var i=0;i<dic.length;i++){
if(dic[i][mode]==arrRoute[depth]){
if(strRoute)strRoute+=","+i;
else strRoute=i.toString();
if(depth==intDepth)return(strRoute);
else depth++;
}
}
return(strRoute);
}
function drawSelect(obj,dicName){
var argv=drawSelect.arguments;
var argc=drawSelect.arguments.length;
var mode=(argc>2)?argv[2]:0;
var name=(argc>3)?argv[3]:"";
var value=(argc>4)?argv[4]:"";
var tips=(argc>5)?argv[5]:"";
var prop=(argc>6)?argv[6]:"";
var beSel=(argc>7)?argv[7]:0;

var dic=eval(dicName),objValue="",noSel=0;
switch(mode){
case 0:value=getRoute(dic,value,2);mode=5;break;
case 1:value=getRoutes(dic,value,1);mode=6;break;
case 2:value=getRoute(dic,value,1);mode=7;break;
case 3:value=getRoutes(dic,value,2);mode=8;break;
}
var strRoute="",arrRoute=new Array();
if(value)arrRoute=value.split(",");
var strHtml="",arrHtml=new Array();
var intDepth,strTitle,strValue,j,selDepth=0;
for(var i=0;i<dic.length;i++){
intDepth=dic[i][0];strTitle=dic[i][1];strValue=dic[i][2];
if(intDepth==selDepth){
if(arrHtml[selDepth]==null){
arrHtml[selDepth]="<select onChange={drawSelect

(this.parentNode,\""+dicName+"\","+mode+",\""+name+"\",this.value,\""+tips+"\",\""+prop+"\","+beSel+")} "+prop+">";
if(tips){
if(beSel)noSel=1;
if(selDepth)arrHtml[selDepth]+="<option

value=\""+strRoute+"\">"+tips+"</option>";
else arrHtml[selDepth]+="<option value=\"\">"+tips+"</option>";
if(arrRoute[selDepth]==null)arrRoute[selDepth]=-1;
}else if(arrRoute[selDepth]==null)arrRoute[selDepth]=i;
}
if(i==arrRoute[selDepth]){
noSel=0;
arrHtml[selDepth]+="<option value=\""+strRoute+i.toString()+"\"

selected>"+strTitle+"</option>";
selDepth++;
strRoute+=i.toString()+",";
switch(mode){
case 5:objValue=strValue;break;
case 6:if(objValue)objValue+=","+strTitle;else objValue=strTitle;break;
case 7:objValue=strTitle;break;
case 8:if(objValue)objValue+=","+strValue;else objValue=strValue;break;
}
}else{
arrHtml[selDepth]+="<option value=\""+strRoute+i.toString()

+"\">"+strTitle+"</option>";
}
}else if(intDepth<selDepth){
selDepth=intDepth;
strRoute="";
for(j=0;j<selDepth;j++)strRoute+=arrRoute[j]+",";
arrHtml[selDepth]+="<option value=\""+strRoute+i.toString()+"\">"+strTitle+"</option>";
}
}
for(i=0;i<arrHtml.length;i++){
strHtml+=arrHtml[i]+"</select>";
}
if(noSel)objValue="";
strHtml+="<input type=\"hidden\" value=\""+objValue+"\" name=\""+name+"\" id=\""+name+"\">";
if(obj==null)document.write("<span>"+strHtml+"</span>");
else obj.innerHTML=strHtml;
}
/* ******************** ******************** ******************************** */
function getRoute(dic,value,mode){
var strRoute,intDepth=-1;
for(var i=dic.length-1;i>-1;i--){
if(intDepth>-1){
if(intDepth==0) return(strRoute);
if(dic[i][0]<intDepth){
strRoute=i+","+strRoute;
intDepth--;
}
}else{
if(dic[i][mode]==value){
strRoute=i.toString();
intDepth=dic[i][0];
}
}
}
return(strRoute);
}

function getRoutes(dic,route,mode){
var strRoute="",depth=0;
var arrRoute=route.split(",");
var intDepth=arrRoute.length-1;
for(var i=0;i<dic.length;i++){
if(dic[i][mode]==arrRoute[depth]){
if(strRoute)strRoute+=","+i;
else strRoute=i.toString();
if(depth==intDepth)return(strRoute);
else depth++;
}
}
return(strRoute);
}
function drawSelect(obj,dicName){
var argv=drawSelect.arguments;
var argc=drawSelect.arguments.length;
var mode=(argc>2)?argv[2]:0;
var name=(argc>3)?argv[3]:"";
var value=(argc>4)?argv[4]:"";
var tips=(argc>5)?argv[5]:"";
var prop=(argc>6)?argv[6]:"";
var beSel=(argc>7)?argv[7]:0;

var dic=eval(dicName),objValue="",noSel=0;
switch(mode){
case 0:value=getRoute(dic,value,2);mode=5;break;
case 1:value=getRoutes(dic,value,1);mode=6;break;
case 2:value=getRoute(dic,value,1);mode=7;break;
case 3:value=getRoutes(dic,value,2);mode=8;break;
}
var strRoute="",arrRoute=new Array();
if(value)arrRoute=value.split(",");
var strHtml="",arrHtml=new Array();
var intDepth,strTitle,strValue,j,selDepth=0;
for(var i=0;i<dic.length;i++){
intDepth=dic[i][0];strTitle=dic[i][1];strValue=dic[i][2];
if(intDepth==selDepth){
if(arrHtml[selDepth]==null){
arrHtml[selDepth]="<select onChange={drawSelect

(this.parentNode,\""+dicName+"\","+mode+",\""+name+"\",this.value,\""+tips+"\",\""+prop+"\","+beSel+")} "+prop+">";
if(tips){
if(beSel)noSel=1;
if(selDepth)arrHtml[selDepth]+="<option

value=\""+strRoute+"\">"+tips+"</option>";
else arrHtml[selDepth]+="<option value=\"\">"+tips+"</option>";
if(arrRoute[selDepth]==null)arrRoute[selDepth]=-1;
}else if(arrRoute[selDepth]==null)arrRoute[selDepth]=i;
}
if(i==arrRoute[selDepth]){
noSel=0;
arrHtml[selDepth]+="<option value=\""+strRoute+i.toString()+"\"

selected>"+strTitle+"</option>";
selDepth++;
strRoute+=i.toString()+",";
switch(mode){
case 5:objValue=strValue;break;
case 6:if(objValue)objValue+=","+strTitle;else objValue=strTitle;break;
case 7:objValue=strTitle;break;
case 8:if(objValue)objValue+=","+strValue;else objValue=strValue;break;
}
}else{
arrHtml[selDepth]+="<option value=\""+strRoute+i.toString()

+"\">"+strTitle+"</option>";
}
}else if(intDepth<selDepth){
selDepth=intDepth;
strRoute="";
for(j=0;j<selDepth;j++)strRoute+=arrRoute[j]+",";
arrHtml[selDepth]+="<option value=\""+strRoute+i.toString()+"\">"+strTitle+"</option>";
}
}
for(i=0;i<arrHtml.length;i++){
strHtml+=arrHtml[i]+"</select>";
}
if(noSel)objValue="";
strHtml+="<input type=\"hidden\" value=\""+objValue+"\" name=\""+name+"\" id=\""+name+"\">";
if(obj==null)document.write("<span>"+strHtml+"</span>");
else obj.innerHTML=strHtml;
}
/* ******************** ******************** ******************************** */
drawSelect(null,"arrArea");//仅仅绘制菜单
document.write("<hr>");
drawSelect(null,"arrArea",1,"strArea","中国大陆,湖南,长沙,长沙市");
document.write("默认中国大陆,湖南,长沙,长沙市");
//-->
</script>


更多的无限级联下拉菜单代码请到论坛查看: http://BBS.TC711.COM



【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】 来源: 互联网    日期:2008-4-30   

发 表 评 论
查看评论

  您的大名:
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
认证编码: 刷新验证码
点评内容: 字数0
  精品推荐  
  本月推荐  
  友情赞助  

关于我们 | 联系我们 | 广告投放 | 留言反馈 | 免费程序 | 虚拟主机 | 网站建设 |  网站推广 |  google_sitemap baidu_sitemap RSS订阅
本站所有资源均来自互联网,如有侵犯您的版权或其他问题,请通知管理员,我们会在最短的时间回复您
Copyright © 2005-2015 Tc711.Com All Rights Reserved 版权所有·711网络   蜀ICP备05021915号
110网监备案 信息产业备案 不良信息举报