我想实现比如我数据库入库的是北京市,那么在C_Province中显示选中的是北京,同时还显示其它的省级数据以便重新选择,数据要与var a = new Array( "110000 ", "110100 ", "110101 ", "110102 "中的数据匹配一下,其它两个select相同,通过这句从数据库调出数据 <SCRIPT language=JavaScript> initialize(User.C_Province, ' <% = Rs( "C_Province ")%> ',User.C_unitcity, ' <% = Rs( "C_unitcity ")%> ',User.C_City, ' <% = Rs( "C_City ")%> ');
</SCRIPT> 来匹配,各位明白否。或可以加个函数来控制也可。
表单代码:
<SCRIPT language=JavaScript src= "../plus/city/changesel.asp "> </SCRIPT>
<SELECT class=form name= "C_Province " onChange= "return changefir(document.UserForm.C_unitcity,document.UserForm.C_City,this.value) ">
<OPTION selected value=999999 selectd> 请选择 </OPTION> </SELECT>
<SELECT class=form name= "C_unitcity " onChange= "return changesec(document.UserForm.C_City,this.value) "> <OPTION selected value=999999> 请选择 </OPTION> </SELECT>
<SELECT class=form name= "C_City "> <OPTION selected value=999999> 请选择 </OPTION> </SELECT>
<SCRIPT language=JavaScript> initialize(UserForm.C_Province, '000000 ',UserForm.C_unitcity, ' <% = RsCorpObj( "C_Province ")%> ',UserForm.C_City, ' <% = RsCorpObj( "C_City ")%> ');
</SCRIPT>
changesel.asp部分代码:
function initialize(firid,firvalue,secid,secvalue,thiid,thivalue)
{
addSel(firid,firvalue,a,b,c);
addSel(secid,secvalue,a,b,c);
addSel(thiid,thivalue,a,b,c);
}
function changefir(secid,thiid,upperid)
{
delSel(secid);
addSel(secid,upperid,a,b,c);
var i = secid[secid.selectedIndex].value;
delSel(thiid);
addSel(thiid,i,a,b,c);
}
function changesec(thiid,upperid)
{
delSel(thiid);
addSel(thiid,upperid,a,b,c);
}
function delSel(id)
{
var len = id.length;
for(i=0;i <len;i++)
{
id.remove(0);
}
}
function addSel(id,upperid,x,y,z)
{
var item;
for(j=0;j <z.length;j++)
{
if(z[j]==upperid)
{
item=new Option(y[j],x[j]);
id.add(item);
}
}
}
function sele(item,val)
{
for(i=0;i <item.length;i++)