[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]
更多实用脚本可访问[url]http://www.popub.net[/url]
[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]