ASP如何触发下拉菜单
我的下拉菜单中的1,2,3,4
如果通过选择下拉菜单,触发SQL语句中的select TOP语句,即top 1,top2 top3,top4.
谢谢!!
参考答案:请参考js实现无限级联动的方法,以下我做一个实例,希望对你有帮助
!--#include file="conn.asp" -->
<script language="JavaScript" type="text/JavaScript">
function GetCity(obj,cityname){
var val = obj.options[obj.selectedIndex].value;
if(cityname=='s'){
mycity=document.form1.s_City;
}else{
mycity=document.form1.e_City;
}
len=mycity.length;
for(i=len-1;i>=0;i--){ //清空城市列表
mycity.options[i]=null;
}
switch(val){
<% Set Rs=conn.execute("Select ID,City from locus where ParentID=0")
Do While Not Rs.eof %>
case "<%=Rs("id")%>":
<% Set Rs1=Conn.execute("Select ID,City from locus where ParentID=" & Rs("ID"))
Do While Not Rs1.eof %>
vn=new Option("<%=Trim(Rs1("City"))%>","<%=Rs1("id")%>"); mycity.add(vn);
<% Rs1.MoveNext
Loop
Set Rs1=Nothing %>
break;
<% Rs.MoveNext
Loop
Set Rs=Nothing %>
}
}
</script>
<table>
<form action="action.asp" name="form1" method="post" onchange="ch(s_Provi,s_City)">
<tr>
<td >起始省份</td>
<td valign=bottom width=170 height=19> <select name="s_Provi" onChange="GetCity(this,'s')">
<option value="" >起始省份</option>
<% Set Rs=conn.execute("Select ID,City from locus where ParentID=0")
Do While Not Rs.eof %>
<option value="<%=Rs("id")%>"><%=Trim(Rs("City"))%></option>
<% Rs.MoveNext
Loop
Set Rs=Nothing %>
</select>
必选</td>
<td >起始城市</td>
<td ><select class=input1 name="s_City">
<option value="" >起始城市</option>
</select>
必选</td>
</tr>
<tr>
<td >到达省份</td>
<td valign=bottom width=170 height=19> <select name="e_Provi" onChange="GetCity(this,'e')">
<option value="" >到达省份</option>
<% Set Rs=conn.execute("Select ID,City from locus where ParentID=0")
Do While Not Rs.eof %>
<option value="<%=Rs("id")%>"><%=Trim(Rs("City"))%></option>
<% Rs.MoveNext
Loop
Set Rs=Nothing %>
</select>
必选</td>
<td >到达城市</td>
<td ><select class=input1 name="e_City">
<option value="" >到达城市</option>
</select>
必选</td>
</tr>
<tr>
<td><input name="提交" type="submit" value="提交"> </td>
</tr>
</form>
</table>