asp搜索栏数据传递问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 23:30:54
我想在首页加上一个搜索代码如下:
<table width="721" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="721" height="117"><form id="form1" name="form1" method="post" action="serchredrect.asp">
<select name="lx" id="lx">
<option selected="selected" value="1">产品搜索</option>
<option value="2">供求信息</option>
<option value="3">企业名录</option>
</select>
<input type="text" name="txtitle" />
<input type="submit" name="Submit" value="搜索" />
</form>
</td>
</tr>
</table>
表单提交由serchredrect.asp处理
serchredrect.asp主要是导向功能
如果用户选产品搜索
就导向产品搜索页面chan

serchredrect.asp 页面可以这么写
<%
txtitle=request("txtitle")
if request("lx")=1 then
response.redirect "chanpin/search.asp?txtitle="&txtitle
end if
if request("lx")=2 then
response.redirect "gongqiu/search.asp?txtitle="&txtitle
end if
if request("lx")=3 then
response.redirect "qiye/search.asp?txtitle="&txtitle
end if
%>

建议你就用一个搜索结果页面(serchredrect.asp)就行了。在这个页面里由搜索表单提供2个参数:lx = Request.QueryString("lx")
txtitle= Request.QueryString("txtitle")
再用SQL查询数据库,显示搜索结果:sql = "select * from 你要查询的表名 where TXTITLE所在字段名 like '%" & txtitle & "%' order by id desc"...

关键是你的产品也企业是不是放在一个表中 如果不是就用IF设置查找表名:if lx="1" then tal="产品表名" else if lx="2" then tal="企业表名"....
然后用tal替换掉sql中的“你要查询的表名”