您的位置:首页 > 其它

两个下拉菜单的二级联动

2008-04-18 22:40 288 查看

<form name="form1" action="search.asp" method="post" >


请选择


<select name="selBigCategory" onChange="TypeChange(this);" >


<%m_SQL="Select ID,Value From CityType order by ID"


Set rs = conn.Execute(m_SQL)


mBigArray = rs.GetRows()


for i=0 to ubound(mBigArray,2)


m_SQL2="Select * From AreaType Where CityTypeID="&mBigArray(0,i)&" order by Grade"


Set rs = conn.Execute(m_SQL2)


strSmallCategory = mBigArray(0,i)&"-"


Do While not rs.Eof


strSmallCategory = strSmallCategory & rs("ID")&"+"&rs("Value")+"-"


rs.Movenext


Loop


Response.write "<option value="&strSmallCategory&">"&mBigArray(1,i)&"</option>"


next


%>


</select>


<script language="javascript">


function TypeChange(theSelect)


{


var sTemp,sString,i,sBigTypeID;


sValue=theSelect.value;


sSubTypeArray=sValue.split("-");


sBigTypeID = sSubTypeArray[0];


sString="<select name='TypeID'>";


sString+="<option value='"+sBigTypeID+":0'>全部</option>";


for(i=1;i<sSubTypeArray.length-1;i++)


{


sTemp=sSubTypeArray[i].split("+");




sString+="<option value='"+sBigTypeID+":"+sTemp[0]+"'>"+sTemp[1]+"</option>";


}


// sString+="<option value='"+sBigTypeID+":0'>全部</option>";


sString+="</Select>"


form1.TypeID.outerHTML=sString;




}


</script>


<select name="TypeID" >


</select>


<script language="javascript">TypeChange(form1.selBigCategory);</script>


</form>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: