asp下拉列表,我想按在列表中选中的值,在数据库中查询怎么实现?我写的代码在下面,各位大哥帮忙指点
<selectname="first"><%sql="select[type_id],[type_name]from[type_tree]"setrs=conn.exec...
<select name="first">
<%
sql = "select [type_id],[type_name] from [type_tree]"
set rs = conn.execute(sql)'取得父类的ID及名称
if rs.eof or rs.bof then
response.write "<option>-----</option>" '如果没有记录,就显示-----
else
while not(rs.eof or rs.bof) '有记录,就将父名称列出来,形成下拉。
response.write ("<option value='?sec=" & rs(0) & "'")
if cstr(rs(0)) = request.querystring("sec") then
response.write "selected"
end if
response.write (">" & rs(1) & "</option>")
rs.movenext
wend
rs.movefirst '将游标移到第一条,以备下面之用。
end if
subrs.close
set subrs = nothing
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</select> 展开
<%
sql = "select [type_id],[type_name] from [type_tree]"
set rs = conn.execute(sql)'取得父类的ID及名称
if rs.eof or rs.bof then
response.write "<option>-----</option>" '如果没有记录,就显示-----
else
while not(rs.eof or rs.bof) '有记录,就将父名称列出来,形成下拉。
response.write ("<option value='?sec=" & rs(0) & "'")
if cstr(rs(0)) = request.querystring("sec") then
response.write "selected"
end if
response.write (">" & rs(1) & "</option>")
rs.movenext
wend
rs.movefirst '将游标移到第一条,以备下面之用。
end if
subrs.close
set subrs = nothing
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</select> 展开
2个回答
展开全部
<select name="first" onChange=openn(this.value)>
<%
sql = "select [type_id],[type_name] from [type_tree]"
set rs = conn.execute(sql)'取得父类的ID及名称
if rs.eof or rs.bof then
response.write "<option>-----</option>" '如果没有记录,就显示-----
else
while not(rs.eof or rs.bof) '有记录,就将父名称列出来,形成下拉。
response.write ("<option value='?sec=" & rs(0) & "'")
if cstr(rs(0)) = request.querystring("sec") then
response.write "selected"
end if
response.write (">" & rs(1) & "</option>")
rs.movenext
wend
rs.movefirst '将游标移到第一条,以备下面之用。
end if
subrs.close
set subrs = nothing
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</select>
<script language=JavaScript>
function openn(){
var args = openn.arguments;
if(args[0] == 0) return;
location.href=(args[0]);
}
</script>
<%
sql = "select [type_id],[type_name] from [type_tree]"
set rs = conn.execute(sql)'取得父类的ID及名称
if rs.eof or rs.bof then
response.write "<option>-----</option>" '如果没有记录,就显示-----
else
while not(rs.eof or rs.bof) '有记录,就将父名称列出来,形成下拉。
response.write ("<option value='?sec=" & rs(0) & "'")
if cstr(rs(0)) = request.querystring("sec") then
response.write "selected"
end if
response.write (">" & rs(1) & "</option>")
rs.movenext
wend
rs.movefirst '将游标移到第一条,以备下面之用。
end if
subrs.close
set subrs = nothing
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</select>
<script language=JavaScript>
function openn(){
var args = openn.arguments;
if(args[0] == 0) return;
location.href=(args[0]);
}
</script>
展开全部
你的意思是1.选择下拉列表就出现查询结果 2.提交后 显示
1.方法一 <select onchange="javascript:location.href=this.value;">
</select>
方法二<select name="first" onChange=openn(this.value)>
</select>
<script language=JavaScript>
function openn(url){
location.href=url;
}
</script>
2.就获取结果就好了
1.方法一 <select onchange="javascript:location.href=this.value;">
</select>
方法二<select name="first" onChange=openn(this.value)>
</select>
<script language=JavaScript>
function openn(url){
location.href=url;
}
</script>
2.就获取结果就好了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询