ASP搜索分页如何传递参数?
从输入框内输入查询条件后,能正确显示第一页,当选择下一页时,不能传递参数,导致不能查询。2个查询条件:selT=关键字selS=类别关键源码如下:<formid="for...
从输入框内输入查询条件后,能正确显示第一页,当选择下一页时,不能传递参数,导致不能查询。
2个查询条件:selT=关键字 selS=类别
关键源码如下:
<form id="form1" name="form1" method="post" action='ds114.asp?act=jq&slt=s&page=1'>
输入关键字:
<input name="selT" type="text" id="selT" />
<select name="selS" id="selS">
<option value="1">店铺名称</option>
<option value="2">电话号码</option>
<option value="3">主营业务</option>
<option value="4">街道范围</option>
</select>
<input type="submit" name="Submit" value="查找" />
</form>
if request.QueryString("slt")="s" then
if request.Form("selT")="" then
response.write"<script>alert('请输入关键字!');history.go(-1);</script>"
response.end
end if
select case request.Form("selS")
case 1
chg=" and [114name] like '%" & trim(request.Form("selT")) & "%'"
case 2
chg=" and [114tel] like '%" & trim(request.Form("selT")) & "%'"
case 3
chg=" and [114FW] like '%" & trim(request.Form("selT")) & "%'"
case 4
chg=" and [114adr] like '%" & trim(request.Form("selT")) & "%'"
end select
set rst114=server.CreateObject("adodb.recordset")
sql114="select * from tbl_dushi114 where [114SH]=1" & chg & " order by [114SZ] asc"
rst114.open sql114,conn,1,1
......
if rst114.recordcount<=0 then
%>
<tr>
<td align="center"> </td>
<td colspan="3">暂无该商家信息,请重新输入关键字查询!</td>
</tr>
<%
else
rst114.pagesize=20
pageCT=rst114.pagecount
page=int(request("page"))
if page<=0 then page=1
if request("page")="" then page=1
rst114.absolutepage=page
for i = 1 to rst114.pagesize
if rst114.eof then exit for
%>
<tr>
<td align="center"><%=rst114("114SZ")%></td>
<td><%=rst114("114name")%></td>
<td><%=rst114("114tel")%></td>
<td><%=rst114("114FW")%></td>
</tr>
<%
rst114.movenext
next
......
<%if pageCT>1 then%>
<%if page=1 and not page=pageCT then %>第一页|上一页|
<a href="ds114.asp?act=jq&slt=s&page=<%=page+1%>">下一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=pageCT%>">|最后页</a>
<% elseif page<>1 and not page=pageCT then %>
<a href="ds114.asp?act=jq&slt=s&page=1">第一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=page-1%>">|上一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=page+1%>">下一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=pageCT%>">|最后页</a>
<% elseif page=pageCT then%>
<a href="ds114.asp?act=jq&slt=s&page=1">第一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=page-1%>">|上一页</a>
|下一页|最后页
直接在Form里面改<form id="form1" name="form1" method="post" action='ds114.asp?act=jq&slt=s&page=1&s1=<%=request.from(selT)%>s2=<%=request.from(selS)%>'>
希望用S1S2来传递参数,然后在后面分页代码里加上这2项
但是,用post不能传递到地址栏,如果连续点两次提交,倒是可以交到地址栏(这个页是个表格页,由上一层页面<!--#include file="ds114jq.asp"-->引用)
用get传递,又不能把act=jq&slt=s&这2个传递上去~~
请高手指点,最好是改改我的代码,谢谢 展开
2个查询条件:selT=关键字 selS=类别
关键源码如下:
<form id="form1" name="form1" method="post" action='ds114.asp?act=jq&slt=s&page=1'>
输入关键字:
<input name="selT" type="text" id="selT" />
<select name="selS" id="selS">
<option value="1">店铺名称</option>
<option value="2">电话号码</option>
<option value="3">主营业务</option>
<option value="4">街道范围</option>
</select>
<input type="submit" name="Submit" value="查找" />
</form>
if request.QueryString("slt")="s" then
if request.Form("selT")="" then
response.write"<script>alert('请输入关键字!');history.go(-1);</script>"
response.end
end if
select case request.Form("selS")
case 1
chg=" and [114name] like '%" & trim(request.Form("selT")) & "%'"
case 2
chg=" and [114tel] like '%" & trim(request.Form("selT")) & "%'"
case 3
chg=" and [114FW] like '%" & trim(request.Form("selT")) & "%'"
case 4
chg=" and [114adr] like '%" & trim(request.Form("selT")) & "%'"
end select
set rst114=server.CreateObject("adodb.recordset")
sql114="select * from tbl_dushi114 where [114SH]=1" & chg & " order by [114SZ] asc"
rst114.open sql114,conn,1,1
......
if rst114.recordcount<=0 then
%>
<tr>
<td align="center"> </td>
<td colspan="3">暂无该商家信息,请重新输入关键字查询!</td>
</tr>
<%
else
rst114.pagesize=20
pageCT=rst114.pagecount
page=int(request("page"))
if page<=0 then page=1
if request("page")="" then page=1
rst114.absolutepage=page
for i = 1 to rst114.pagesize
if rst114.eof then exit for
%>
<tr>
<td align="center"><%=rst114("114SZ")%></td>
<td><%=rst114("114name")%></td>
<td><%=rst114("114tel")%></td>
<td><%=rst114("114FW")%></td>
</tr>
<%
rst114.movenext
next
......
<%if pageCT>1 then%>
<%if page=1 and not page=pageCT then %>第一页|上一页|
<a href="ds114.asp?act=jq&slt=s&page=<%=page+1%>">下一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=pageCT%>">|最后页</a>
<% elseif page<>1 and not page=pageCT then %>
<a href="ds114.asp?act=jq&slt=s&page=1">第一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=page-1%>">|上一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=page+1%>">下一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=pageCT%>">|最后页</a>
<% elseif page=pageCT then%>
<a href="ds114.asp?act=jq&slt=s&page=1">第一页</a>
<a href="ds114.asp?act=jq&slt=s&page=<%=page-1%>">|上一页</a>
|下一页|最后页
直接在Form里面改<form id="form1" name="form1" method="post" action='ds114.asp?act=jq&slt=s&page=1&s1=<%=request.from(selT)%>s2=<%=request.from(selS)%>'>
希望用S1S2来传递参数,然后在后面分页代码里加上这2项
但是,用post不能传递到地址栏,如果连续点两次提交,倒是可以交到地址栏(这个页是个表格页,由上一层页面<!--#include file="ds114jq.asp"-->引用)
用get传递,又不能把act=jq&slt=s&这2个传递上去~~
请高手指点,最好是改改我的代码,谢谢 展开
5个回答
展开全部
建立access的数据库news,还有表news,表的字段(id,title),id唯一,输入数据保存,用下面代码可查询,可分页
-----------------------下面保存为search.asp--------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件</title>
</head>
<body bgcolor="#ffffff">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script>
function btn_ck_bh_Click()
{
var cx = document.form1.cxsj.value;
form1.action ="search.asp?cx="+cx;
}
</script>
<table border="1" cellspacing="0" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="88%" style="word-break:break-all">
<tr>
<td width="778" align="center" colspan="7">
<form method="POST" name="form1" action=search.asp>
<p>输入搜索内容:<input type="text" name="cxsj" size="20"><input type="submit" value="提交" name="B1" LANGUAGE="javascript" onclick="btn_ck_bh_Click()">
<input type="reset" value="重写" name="B2"></p>
</form>
</td>
</tr>
</table>
<table border="1" cellspacing="0" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="88%" style="word-break:break-all">
<tr>
<td width="8%" align="center"><strong><font color="#0080C0">ID 号</font></strong></td>
<td width="58%" align="center"><strong><font color="#0080C0">标 题</font></strong></td>
<td width="8%" align="center"><strong><font color="#0080C0">修 改</font></strong></td>
<td width="8%" align="center"><strong><font color="#0080C0">删 除</font></strong></td>
</tr>
<%
'数据库查询
'获得搜索内容
cx = request("cx")
dim pageCount
'把page转换成整数
page = cint(request("page"))
set conn=server.createobject("adodb.connection")'
set rs=server.createobject("adodb.recordset")
conn.open "DBQ=" & server.mappath("./news.mdb") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
' 获取产品的名字记录集(从 news表中)
if cx <> "" then
sql = "select * from news where title like '%"&cx& "%' order by id desc"
else
sql ="select * from news order by id desc"
end if
rs.open sql,conn,3,3
'如果没有数据记录
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,请返回!!"
response.write errmsg
response.end
end if
' 设置记录集在每页的总行数,也就是 PageSize属性
RS.PageSize=40
'把rs.pageCount转换成整数和page才能作比较
pageCount = cint(rs.pageCount)
' 设置当前的页号( AbsolutePage属性)
if page = 0 then
page =1
end if
RS.AbsolutePage = page
x=1
' 显示当前页中的所有记录( PageSize中设置的行数)
WHILE NOT RS.EOF AND NumRows<RS.PageSize
%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="8%"><p align="center"><%=rs("id")%></td>
<td width="58%"><a href="view.asp?id=<%=rs("id")%>" target="_blank"><%=rs("title")%></a></td>
<td width="8%" align="center"><a href="edit.asp?id="<%=rs("id")%>>修 改</a></td>
<td width="8%" align="center"><a href="delet.asp?id="<%=rs("id")%>>删 除</a></td>
</tr>
<%RS.MoveNext
NumRows=NumRows+1
WEND%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="105%" align="center" colspan="6"> </td> </tr>
<tr>
<td width="105%" align="center" colspan="6">
<p align="center"><FONT color=#333333>共<%=PageCount%>页 第<%=page%>页★
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>
<A HREF="search.asp?page=1&cx=<%=cx%>"> 首页</A>
<%end if%>★
<%if page>1 then%><A HREF="search.asp?page=<%=page-1%>&cx=<%=cx%>"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p = 1
'把pagewhere转换成整数
'pagewhere = cint(request("pagewhere"))
pagewhere = pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p <> page then%>
<A HREF="search.asp?page=<%=p%>&cx=<%=cx%>"><%=p%></a>
<%end if
if p =page then%>
<%=p%>
<% end if
next
end if%>
<%if page < PageCount then%>
<A HREF="search.asp?page=<%=page+1%>&cx=<%=cx%>">
<%end if %>下一页</A>★
<%if page=PageCount then%>尾页
<%end if%>
<%if page<PageCount then%>
<A HREF="search.asp?page=<%=PageCount%>&cx=<%=cx%>"> 尾页</A>
<%end if%>
</p></FONT></td> </tr> <tr>
<td width="105%" align="center" colspan="6">搜索内容:<%=cx%></td>
</tr>
</table></center></div>
</body></html>
<%
rs.close
Set rs=nothing
conn.close
set conn=nothing
%>
-----------------------下面保存为search.asp--------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>文件</title>
</head>
<body bgcolor="#ffffff">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<script>
function btn_ck_bh_Click()
{
var cx = document.form1.cxsj.value;
form1.action ="search.asp?cx="+cx;
}
</script>
<table border="1" cellspacing="0" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="88%" style="word-break:break-all">
<tr>
<td width="778" align="center" colspan="7">
<form method="POST" name="form1" action=search.asp>
<p>输入搜索内容:<input type="text" name="cxsj" size="20"><input type="submit" value="提交" name="B1" LANGUAGE="javascript" onclick="btn_ck_bh_Click()">
<input type="reset" value="重写" name="B2"></p>
</form>
</td>
</tr>
</table>
<table border="1" cellspacing="0" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolordark="#ECF5FF" width="88%" style="word-break:break-all">
<tr>
<td width="8%" align="center"><strong><font color="#0080C0">ID 号</font></strong></td>
<td width="58%" align="center"><strong><font color="#0080C0">标 题</font></strong></td>
<td width="8%" align="center"><strong><font color="#0080C0">修 改</font></strong></td>
<td width="8%" align="center"><strong><font color="#0080C0">删 除</font></strong></td>
</tr>
<%
'数据库查询
'获得搜索内容
cx = request("cx")
dim pageCount
'把page转换成整数
page = cint(request("page"))
set conn=server.createobject("adodb.connection")'
set rs=server.createobject("adodb.recordset")
conn.open "DBQ=" & server.mappath("./news.mdb") & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
' 获取产品的名字记录集(从 news表中)
if cx <> "" then
sql = "select * from news where title like '%"&cx& "%' order by id desc"
else
sql ="select * from news order by id desc"
end if
rs.open sql,conn,3,3
'如果没有数据记录
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,请返回!!"
response.write errmsg
response.end
end if
' 设置记录集在每页的总行数,也就是 PageSize属性
RS.PageSize=40
'把rs.pageCount转换成整数和page才能作比较
pageCount = cint(rs.pageCount)
' 设置当前的页号( AbsolutePage属性)
if page = 0 then
page =1
end if
RS.AbsolutePage = page
x=1
' 显示当前页中的所有记录( PageSize中设置的行数)
WHILE NOT RS.EOF AND NumRows<RS.PageSize
%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="8%"><p align="center"><%=rs("id")%></td>
<td width="58%"><a href="view.asp?id=<%=rs("id")%>" target="_blank"><%=rs("title")%></a></td>
<td width="8%" align="center"><a href="edit.asp?id="<%=rs("id")%>>修 改</a></td>
<td width="8%" align="center"><a href="delet.asp?id="<%=rs("id")%>>删 除</a></td>
</tr>
<%RS.MoveNext
NumRows=NumRows+1
WEND%>
<tr onmouseover="this.bgColor='#99ccff'" onmouseout="this.bgColor=''">
<td width="105%" align="center" colspan="6"> </td> </tr>
<tr>
<td width="105%" align="center" colspan="6">
<p align="center"><FONT color=#333333>共<%=PageCount%>页 第<%=page%>页★
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>
<A HREF="search.asp?page=1&cx=<%=cx%>"> 首页</A>
<%end if%>★
<%if page>1 then%><A HREF="search.asp?page=<%=page-1%>&cx=<%=cx%>"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p = 1
'把pagewhere转换成整数
'pagewhere = cint(request("pagewhere"))
pagewhere = pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p <> page then%>
<A HREF="search.asp?page=<%=p%>&cx=<%=cx%>"><%=p%></a>
<%end if
if p =page then%>
<%=p%>
<% end if
next
end if%>
<%if page < PageCount then%>
<A HREF="search.asp?page=<%=page+1%>&cx=<%=cx%>">
<%end if %>下一页</A>★
<%if page=PageCount then%>尾页
<%end if%>
<%if page<PageCount then%>
<A HREF="search.asp?page=<%=PageCount%>&cx=<%=cx%>"> 尾页</A>
<%end if%>
</p></FONT></td> </tr> <tr>
<td width="105%" align="center" colspan="6">搜索内容:<%=cx%></td>
</tr>
</table></center></div>
</body></html>
<%
rs.close
Set rs=nothing
conn.close
set conn=nothing
%>
展开全部
举例说明:
你地址栏中的地址是:
www.abc.com/page.asp?page=1&keyword=aaa&class=2&gender=1&option=1
分页中有显示数字页面,或者上一页下一页这种的显示风格,在链接中直接接收所有地址栏参数即可,例:
<a href=http://www.abc.com/page.asp?page=<%=page%>&keyword=<%=request.form("keyword")%>&....>首页</a>
有多少个参数,写接收多少个参数,注意做好防注入即可
你地址栏中的地址是:
www.abc.com/page.asp?page=1&keyword=aaa&class=2&gender=1&option=1
分页中有显示数字页面,或者上一页下一页这种的显示风格,在链接中直接接收所有地址栏参数即可,例:
<a href=http://www.abc.com/page.asp?page=<%=page%>&keyword=<%=request.form("keyword")%>&....>首页</a>
有多少个参数,写接收多少个参数,注意做好防注入即可
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
翻页的参数ds114.asp?act=jq&slt=s&page=1&sltS=trim(request("selS"))
下面这部分改为如下:
select case trim(request("selS"))
case 1
chg=" and [114name] like '%" & trim(request.Form("selT")) & "%'"
case 2
chg=" and [114tel] like '%" & trim(request.Form("selT")) & "%'"
case 3
chg=" and [114FW] like '%" & trim(request.Form("selT")) & "%'"
case 4
chg=" and [114adr] like '%" & trim(request.Form("selT")) & "%'"
end select
下面这部分改为如下:
select case trim(request("selS"))
case 1
chg=" and [114name] like '%" & trim(request.Form("selT")) & "%'"
case 2
chg=" and [114tel] like '%" & trim(request.Form("selT")) & "%'"
case 3
chg=" and [114FW] like '%" & trim(request.Form("selT")) & "%'"
case 4
chg=" and [114adr] like '%" & trim(request.Form("selT")) & "%'"
end select
参考资料: www.5usite.com
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你在上一页、下一页、第一页,最后一页,这些链接后面加上哪两个参数就可以了,就像这样
<a href="ds114.asp?act=jq&slt=s&page=<%=page+1%>&selT=<%=request("selT")%>&selS=<%=request("selS")%>">下一页</a>
就可以了
<a href="ds114.asp?act=jq&slt=s&page=<%=page+1%>&selT=<%=request("selT")%>&selS=<%=request("selS")%>">下一页</a>
就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<a href="ds114.asp?act=jq&slt=s&page=<%=page+1%>">下一页</a>
你把搜索的关键字 的参数也加到这个连接上!就可以了!!
你把搜索的关键字 的参数也加到这个连接上!就可以了!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询