省、市、地区联动选择实用脚本

[size=medium]省、市、区三级级联使用脚本,效果图如下:[/size]
[img]http://dl.iteye.com/upload/picture/pic/122772/db8053d9-021d-3f5e-97b5-3bb36127f7a6.jpg[/img]

[size=medium][color=red]范例代码见附件[/color],其中核心脚本如下:[/size]
 function PCAS(){
this.SelP=document.getElementsByName(arguments[0])[0];
this.SelC=document.getElementsByName(arguments[1])[0];
this.SelA=document.getElementsByName(arguments[2])[0];
this.DefP=this.SelA?arguments[3]:arguments[2];
this.DefC=this.SelA?arguments[4]:arguments[3];
this.DefA=this.SelA?arguments[5]:arguments[4];
this.SelP.PCA=this;this.SelC.PCA=this;
this.SelP.onchange=function()
{
PCAS.SetC(this.PCA)
};
if(this.SelA)
this.SelC.onchange=function()
{
PCAS.SetA(this.PCA)
};
PCAS.SetP(this)
};

PCAS.SetP=function(PCA)
{
for(i=0;i<PCAP.length;i++)
{
PCAPT=PCAPV=PCAP[i];
if(PCAPT==SPT)
PCAPV="";
PCA.SelP.options.add(new Option(PCAPT,PCAPV));
if(PCA.DefP==PCAPV)
PCA.SelP[i].selected=true
}
PCAS.SetC(PCA)
};

PCAS.SetC=function(PCA)
{
PI=PCA.SelP.selectedIndex;
PCA.SelC.length=0;
for(i=1;i<PCAC[PI].length;i++)
{
PCACT=PCACV=PCAC[PI][i];
if(PCACT==SCT)
PCACV="";
PCA.SelC.options.add(new Option(PCACT,PCACV));
if(PCA.DefC==PCACV)
PCA.SelC[i-1].selected=true
}
if(PCA.SelA)
PCAS.SetA(PCA)
};

PCAS.SetA=function(PCA)
{
PI=PCA.SelP.selectedIndex;
CI=PCA.SelC.selectedIndex;
PCA.SelA.length=0;
for(i=1;i<PCAA[PI][CI].length;i++)
{
PCAAT=PCAAV=PCAA[PI][CI][i];
if(PCAAT==SAT)
PCAAV="";
PCA.SelA.options.add(new Option(PCAAT,PCAAV));
if(PCA.DefA==PCAAV)
PCA.SelA[i-1].selected=true
}
}

更多实用脚本可访问[url]http://www.popub.net[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值