关于select取值保留的问题

xp6756 2014-09-01 03:28:06

<form name="form1" method="post" action="searchitem3.asp">
<table width="1060" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#C0C0C0" style="border-collapse: collapse">

<tr align="center" valign="middle">
<td height="30" colspan="9" bgcolor="#ffffff" >
搜索:


<select name="city_name" id="city_name">
<%
set rs_City=server.createobject("adodb.recordset")
sql="select * from [city] order by ID desc"
rs_City.open sql,conn,1,1 %>


<option value="">全部</option>



<%while not rs_City.eof%>

<option value="<%=rs_City("city_name")%>"><%=trim(rs_City("city_name"))%></option>






<%
rs_City.movenext
wend
rs_City.close
set rs_City=nothing
%>

</select>
<input name="school_name" type="text" id="school_name" size="10" maxlength="30" value="<%=request("school_name")%>">
<input name="submit" type="submit" id="submit" value="查询">


</td></tr></table></form>

能不能帮俺看看这个select怎么设置一下才能实现保留选择值

【新人】回不去的好时光 2014/9/1 15:10:30
就是说选好值后点击查询后,select框里的取值是刚才选好的值
...全文
112 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
xp6756 2014-09-01
  • 打赏
  • 举报
回复
引用 1 楼 superwfei 的回复:
while not rs_City.eof
   Response.Write "<option value=""" & rs_City("city_name") & """"
   If Request("city_name") = rs_City("city_name") Then Response.Write " selected"
   Response.Write ">" & trim(rs_City("city_name")) & "</option>"
   rs_City.movenext
   wend
这个问题我解决了,还是帮我解决下那个查询分页的问题吧!谢谢了!
文盲老顾 2014-09-01
  • 打赏
  • 举报
回复
while not rs_City.eof
   Response.Write "<option value=""" & rs_City("city_name") & """"
   If Request("city_name") = rs_City("city_name") Then Response.Write " selected"
   Response.Write ">" & trim(rs_City("city_name")) & "</option>"
   rs_City.movenext
   wend

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧