ASP分页,下一页无法取复选框的值

wsmhzyaba 2011-08-24 01:31:20
<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%dim action,searchkey,categoryid,jiage,shape,rs2,zkou,rs3,carat,caratpage
dim good,clar,cut,polish,tosay,arrows,zstype,fluore,bqj1,bqj2,goods
shape=request("shape")
good=request("good")
clar=request("clar")
cut=request("cut")
bqj1=request("bqj1")
bqj2=request("bqj2")
polish=request("polish")
tosay=request("tosay")
arrows=request("arrows")
zstype=request("zstype")
fluore=request("fluore")
categoryid=request.form("categoryid")
jiage=request.form("jiage")
action=request.QueryString("action")
searchkey=request.QueryString("searchkey")
if request("bqj1")<>"" then
caratpage=caratpage&"bqj1="&bqj1
end if
if request("bqj2")<>"" then
caratpage=caratpage&"&bqj2="&bqj2
end if

if categoryid="" then categoryid=request.QueryString("categoryid")
if jiage="" then jiage=request.QueryString("jiage")
if action="" then action=int(request.form("action"))
if searchkey="" then searchkey=trim(request.form("searchkey"))


%>
<%call sss()%>
<title><%=webname%>--商品搜索结果</title>
<!--#include file="include/header.asp"-->
<TABLE WIDTH="973" BORDER="0" CELLSPACING="0" CELLPADDING="0" ALIGN="CENTER" BGCOLOR=<%=bgclr1%>>
<TR><TD WIDTH="760" BGCOLOR=<%=bgclr1%> HEIGHT="22" ALIGN="CENTER">
<B><FONT COLOR="#FFFFFF">搜索结果</FONT></B></TD></TR></TABLE>
<table width="973" border="0" cellspacing="1" cellpadding="0" align="center" BGCOLOR=<%=bgclr1%>>
<tr> <td HEIGHT="200" VALIGN="TOP" BGCOLOR=<%=bgclr4%> WIDTH="100%"> <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr> <td style="padding-left:6px"> <%if searchkey="" then
response.write "对不起,请您输入查询关键字"
response.End
else
response.write "您查询的关健字是:<font color=red>"&searchkey&"</font>"
end if%> </td></tr> </table><%'开始分页
Const MaxPerPage=20
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if

set rs=server.CreateObject("adodb.recordset")
if jiage="" then '//普通查询
select case action
case "1"
rs.open "select * from product where name like '%"&searchkey&"%' ",conn,1,1
case "2"
rs.open "select id,name,good,mark,introduce,price1,price2,discount,productdate from product where mark like '%"&searchkey&"%' ",conn,1,1
case "3"
rs.open "select id,name,good,mark,introduce,price1,price2,discount,productdate from product where introduce like '%"&searchkey&"%' ",conn,1,1
case "4"
rs.open "select id,name,good,mark,introduce,price1,price2,discount,detail,productdate from product where detail='"&searchkey&"' ",conn,1,1
end select
else
'//高级查询

if categoryid<>0 then '//判断查询分类,分类不为空。
select case action
case "1"
rs3="select * from product where name like '%"&searchkey&"%' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluors in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
case "2"
rs3="select * from product where mark like '%"&searchkey&"%' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluore in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
case "3"
rs3="select * from product where introduce like '%"&searchkey&"%' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluors in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
case "4"
rs3="select * from product wheree detail='"&searchkey&"' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if
if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluors in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
end select
else
'//分类为空。

select case action
case "1"
rs3="select * from product where name like '%"&searchkey&"%' and price1<"&jiage&" "
if request("zstype") <>"" then
rs3=rs3&"and zstype in ("&zstype&")"
end if
if request("shape") <>"" then
rs3=rs3&"and shape in ("&shape&")"
end if
if request("good")<>"" then
rs3=rs3&"and good in("&good&")"
end if
if request("bqj1")<>"" then
rs3=rs3&"and carat > ("&bqj1&") and carat<("&bqj2&")"
end if

if request("clar")<>"" then
rs3=rs3&"and clar in ("&clar&")"
end if
if request("cut")<>"" then
rs3=rs3&"and cut in ("&cut&")"
end if
if request("polish")<>"" then
rs3=rs3&"and polish in ("&polish&")"
end if
if request("tosay")<>"" then
rs3=rs3&"and tosay in ("&tosay&")"
end if
if request("arrows")<>"" then
rs3=rs3&"and arrows in ("&arrows&")"
end if
if request("fluore")<>"" then
rs3=rs3&"and fluore in ("&fluore&")"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open rs3,conn,1,1
case "2"
rs.open "select * where mark like '%"&searchkey&"%' and good in ("&good&") and zstype in ("&zstype&") and shape in ("&shape&") and price2<"&jiage,conn,1,1
case "3"
rs.open "select * from product where introduce like '%"&searchkey&"%' and good in ("&good&") and zstype in ("&zstype&") and shape in ("&shape&") and price2<"&jiage,conn,1,1
case "4"
rs.open "select * from product where detail='"&searchkey&"' and good in ("&good&") and zstype in ("&zstype&") and shape in ("&shape&") and price2<"&jiage,conn,1,1
end select
end if
end if
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
quweiie 2011-08-25
  • 打赏
  • 举报
回复

<a href='javascript:doSearch(page)'>下一页</a>
也可以加个参数page
function doSearch(pagenum){
for(){.........}
if(pagenum!=''){strUrl+='&page='&pagenum;}
$.get(strUrl,function(msg){$('#list').html(msg);});
}
quweiie 2011-08-25
  • 打赏
  • 举报
回复

如果你懂jquery,就好了.
示例:
<form id='searchForm'>
<input type='text' id='username' />
<input type='checkbox' id='ofun' value='1' />
<input type='button' id='' value='search' />
</form>
<div id='list'></div>
<script src='jquery.js'></script>
<script>
function doSearch(){
strUrl='dataList.asp?act=s';
for(var j=0;j<document.forms[0].elements.length;j++){
if(document.forms[0].elements[j].value!=''){
if(document.forms[0].elements[j].type='checkbox'&&document.forms[0].elements[j].checked){
strUrl+='&'+document.forms[0].elements[j].id+'='+document.forms[0].elements[j].value
}
else{
strUrl+='&'+document.forms[0].elements[j].id+'='+document.forms[0].elements[j].value;}
}
}
$.get(strUrl,function(msg){$('#list').html(msg);})
}
</script>
后台dataList.asp
<%
dim username,ofun
ofun=request.querystring("ofun")
username=request.querystring("username")
下面就按照你普通分页写法 写就行了.....
只不过<a href='javascript:gopage(1)'>First</a>
<a href='javascript:gopage("&page&"+1)'>Next</a>
%>
wsmhzyaba 2011-08-24
  • 打赏
  • 举报
回复
到下一页的时候不能确定GOOD的值
因为GOOD是复选框
应该怎么取呢
wsmhzyaba 2011-08-24
  • 打赏
  • 举报
回复
这里的分面里面有一段
<form method=Post action=<% = filename %>?searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&clar=<%=clar%>&<%=caratpage%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>
<% If CurrentPage<2 Then %>
<div align="center">首 页 上一页
<% Else %>
<div align="center"><a href=<% = filename %>?page=1&searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&clar=<%=clar%>&<%=caratpage%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>首 页</a>
<a href=<% = filename %>?page=<% = CurrentPage-1 %>&searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&clar=<%=clar%>&<%=caratpage%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>上一页</a>
<% End If
If n-currentpage<1 Then %>
下一页 末 页

<% Else %>
<a href=<% = filename %>?page=<% = (CurrentPage+1) %>&searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&<%=caratpage%>&clar=<%=clar%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>下一页</a>
<a href=<% = filename %>?page=<% = n %>&searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&<%=caratpage%>&clar=<%=clar%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>末 页</a>
<% End If %>
第 <b><% = CurrentPage %></b> 页 共 <b><% = n %></b> 页
共查询到 <b><% = totalnumber %></b> 件商品
转到第<input type="text" name="page" size=2 maxlength=10 value=<% = currentpage %>>
页<input type='submit' class='contents' value='跳转' name='cndok'></div></form>



wsmhzyaba 2011-08-24
  • 打赏
  • 举报
回复



if err.number<>0 then
response.write "数据库中暂时无数据"
end if

if rs.eof And rs.bof then
Response.Write "<p align='center' > 对不起,没有查询到您需要的商品!</p>"
else
totalPut=rs.recordcount

if currentpage<1 then
currentpage=1
end if

if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if

if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"research.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"research.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"research.asp"
end if
end if
end if

sub showContent
dim i
i=0

%>
<table width=973 border="0" align="center" cellpadding="6" cellspacing="0">
<tr align="center" bgcolor=<%=bgclr1%> height=22>
<td width="67"><FONT COLOR="#FFFFFF">编号</FONT></td>
<td width="53"> <FONT COLOR="#FFFFFF">颜色</FONT></td>
<td width="46"> <FONT COLOR="#FFFFFF">证书</FONT></td>
<td width="46"> <FONT COLOR="#FFFFFF">形状</FONT></td>
<td width="32"> <FONT COLOR="#FFFFFF">重量</FONT></td>
<td width="46"> <FONT COLOR="#FFFFFF">证书号</FONT></td>
<td width="70"> <FONT COLOR="#FFFFFF">净度</FONT></td>
<td width="49"> <FONT COLOR="#FFFFFF">切工</FONT></td>
<td width="49"> <FONT COLOR="#FFFFFF">抛光</FONT></td>
<td width="49"> <FONT COLOR="#FFFFFF">对称</FONT></td>
<td width="49"> <FONT COLOR="#FFFFFF">荧光</FONT></td>
<td width="49"> <FONT COLOR="#FFFFFF">台宽比</FONT></td>
<td width="49"> <FONT COLOR="#FFFFFF">亭深比</FONT></td>
<td width="58"> <FONT COLOR="#FFFFFF">直径</FONT></td>
<td width="58"> <FONT COLOR="#FFFFFF">价格</FONT></td>
</tr>
<%do while not rs.eof%>
<tr align="center" height="10"> <%Dim num1 '//判断数字奇偶
num1 = Num1+1
If num1 Mod 2 = 0 Then%>
<td style="padding-left:6px" align="left" height="10"><%response.write "<a href=product.asp?id="&trim(rs("id"))&" target=_blank>"&trim(rs("name"))&"</a>"%> </td>
<td bordercolor="#FFCCCC"><%=trim(rs("good"))%></td>
<td bordercolor="#FFCCCC"><%=trim(rs("zstype"))%></td>
<td bordercolor="#FFCCCC"><%=rs("shape")%></td>
<td bordercolor="#FFCCCC"><font color=#FF0000><%=formatnumber(rs("carat"),-1,-1)%></font></td>
<td bordercolor="#FFCCCC"><font color=#FF0000><%=rs("pretype")%></font></td>
<td bordercolor="#FFCCCC"><%=rs("clar")%></td>
<td bordercolor="#FFCCCC"><%=rs("cut")%></td>
<td bordercolor="#FFCCCC"><%=rs("polish")%></td>
<td bordercolor="#FFCCCC"><%=rs("tosay")%></td>
<td bordercolor="#FFCCCC"><%=rs("fluore")%></td>
<td bordercolor="#FFCCCC"><%=rs("mesa")%></td>
<td bordercolor="#FFCCCC"><%=rs("depth")%></td>

<td><a href=# onClick="javascript:window.open('cart.asp?id=<% = rs("id") %>','','width=632,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"><img src=images/skin/default/cart.gif width=50 height=19 align=absmiddle border=0></a> <a href=# onClick="javascript:window.open('addto.asp?id=<% = rs("id") %>&action=add','','width=632,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"><img src=images/skin/default/addto.gif width=50 height=19 align=absmiddle border=0></a></td>
<td><%=rs("price1")%>元</td>

<%else%>
<td style="padding-left:6px" align="left" ><%response.write "<a href=product.asp?id="&trim(rs("id"))&" target=_blank>"&trim(rs("name"))&"</a>"%> </td>
<td bordercolor="#FFCCCC"><%=trim(rs("good"))%></td>
<td bordercolor="#FFCCCC"><%=trim(rs("zstype"))%></td>
<td bordercolor="#FFCCCC"><%=rs("shape")%></td>
<td bordercolor="#FFCCCC"><font color=#FF0000><%=formatnumber(rs("carat"),-1,-1)%></font></td>
<td bordercolor="#FFCCCC"><font color=#FF0000><%=rs("pretype")%></font></td>
<td bordercolor="#FFCCCC"><%=rs("clar")%></td>
<td bordercolor="#FFCCCC"><%=rs("cut")%></td>
<td bordercolor="#FFCCCC"><%=rs("polish")%></td>
<td bordercolor="#FFCCCC"><%=rs("tosay")%></td>
<td bordercolor="#FFCCCC"><%=rs("fluore")%></td>
<td bordercolor="#FFCCCC"><%=rs("mesa")%></td>
<td bordercolor="#FFCCCC"><%=rs("depth")%></td>

<td><a href=# onClick="javascript:window.open('cart.asp?id=<% = rs("id") %>','','width=632,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"><img src=images/skin/default/cart.gif width=50 height=19 align=absmiddle border=0></a> <a href=# onClick="javascript:window.open('addto.asp?id=<% = rs("id") %>&action=add','','width=632,height=388,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');return false;"><img src=images/skin/default/addto.gif width=50 height=19 align=absmiddle border=0></a></td>
<td><%=rs("price1")%>元</td>
<%end if

%> </tr>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop

rs.close
set rs=nothing


%></table><%
End Sub

Function showpage(totalnumber,maxperpage,filename)
Dim n

If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If %>

<form method=Post action=<% = filename %>?searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&clar=<%=clar%>&<%=caratpage%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>
<% If CurrentPage<2 Then %>
<div align="center">首 页 上一页
<% Else %>
<div align="center"><a href=<% = filename %>?page=1&searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&clar=<%=clar%>&<%=caratpage%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>首 页</a>
<a href=<% = filename %>?page=<% = CurrentPage-1 %>&searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&clar=<%=clar%>&<%=caratpage%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>上一页</a>
<% End If
If n-currentpage<1 Then %>
下一页 末 页

<% Else %>
<a href=<% = filename %>?page=<% = (CurrentPage+1) %>&searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&<%=caratpage%>&clar=<%=clar%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>下一页</a>
<a href=<% = filename %>?page=<% = n %>&searchkey=<% = searchkey %>&action=<% = action %>&categoryid=<% = categoryid %>&jiage=<% = jiage %>&good=<%=good %>&zstype=<% = zstype %>&shape=<% = shape %>&<%=caratpage%>&clar=<%=clar%>&cut=<%=cut%>&polish=<%=polish%>&tosay=<%=tosay%>&fluore=<%=fluore%>>末 页</a>
<% End If %>
第 <b><% = CurrentPage %></b> 页 共 <b><% = n %></b> 页
共查询到 <b><% = totalnumber %></b> 件商品
转到第<input type="text" name="page" size=2 maxlength=10 value=<% = currentpage %>>
页<input type='submit' class='contents' value='跳转' name='cndok'></div></form>
<%
End Function
sub sss()
if action="1" then
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from keyname where keyname='"&searchkey&"' ",conn,1,3
if rs.eof and rs.bof then
rs.close
rs.open "select * from keyname",conn,1,3
rs.addnew
rs("keyname")=searchkey
rs("keyorder")=1
rs.update
rs.close
set rs=nothing
else
rs("keyorder")=rs("keyorder")+1
rs.update
rs.close
set rs=nothing
end if
end if

end sub%> </td></tr> </table>
<!--#include file="include/footer.asp"-->

28,391

社区成员

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

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