编程社区 » asp编程 » 请问各位大哥这种分页效果如何做 “上5页 1.2.3.4.5... 下5页 ”,小妹有劳各位大哥了

请问各位大哥这种分页效果如何做 “上5页 1.2.3.4.5... 下5页 ”,小妹有劳各位大哥了


amanda2002



 发表:

请问各位大哥这种分页效果如何做 “上5页 1.2.3.4.5... 下5页 ”,小妹有劳各位大哥了


上5页 1.2.3.4.5... 下5页
———



上5页 ...6.7.8.9.10... 下5页
_____ _____


moodboy1982
回复:

这个是分页程序。
只是在下面一下显示5个页。也就是循环显示5次。当选择下5页时,再把变量改变下移,循环显示下5页。






---------------个性签名-------------
http://www.esoftnow.com/bbs
WEB技术论坛,发贴有奖

sdxlh007
回复:

和分页差不多嘛,加个判断条件就可以

toumh
回复:

For i=1 to PageCount
Response.Write("<a href='XXX.asp?page="& i &"'>"& i &"</a>")
Next

lnboy1003
回复:

<%sub listpages()
if pages<1 then
exit sub
end if
response.write "Pages:"
if p>0 then
response.write "<a href="&request.ServerVariables("script_name")&"?currentpage=10&p="&p-1&">Previous 10 Results</a> "
end if
'-------------------下面写出当前十个页码
for i=1 to 10
if (p*10+i)>pages then exit for
if currentpage=i then
response.write "<a style='color:blue' "
else
response.write "<a "
end if
response.write "href="&request.ServerVariables("script_name")&"?currentpage="&i&"&p="&p&">["&(p*10+i)&"]</a> "
next
'--------------------察看下十页的连接
if (p*10+10)<pages then
response.write "<a href="&request.ServerVariables("script_name")&"?currentpage=10&p="&p+1&">Next 10 Results</a>"
end if

end sub

sub myPages(myRS,mysize) '------mysize为内部变量(主页面没有定义),myRS为主页面传递过来的RS对象(地址传递)
if myRS.eof and myRS.bof then str="No Information!"
if str="" then
if mysize="" or NOT IsNumeric(mysize) then
mysize=15
end if
myRS.PageSize=mysize
pages=myRS.pagecount
records=myRS.recordcount
On Error Resume Next '取得数字
currentPage=request("currentPage")
if currentPage="" then
currentPage=1
end if
currentPage=CInt(currentPage)
if Err.Number <> 0 Then
currentPage=1
Err.Clear
end if
if currentPage <1 then
currentPage = 1
elseIf currentPage >10 then
currentPage=10
end if
'----------------处理p
p=request("p")
if p="" then
p=0
end if
p=CLng(p)
if Err.Number <> 0 Then
p=0
Err.Clear
end if
if p<0 then
p=0
end if
'--判断是否出了页数范围
nowPage=p*10+currentPage
if nowPage>pages then
p=(pages-1)\10
currentPage=((pages-1) mod 10)+1
end if
myRS.absolutepage=p*10+currentPage
else
currentPage=1
records=0
pages=1
end if
end sub

dim pages,records,currentPage,p '--------定义变量,这些变量在主页面中,进行地址传递%>


fangq
回复:

留下Mail,发给你

sy_binbin
回复:

<%
set con=server.CreateObject("ADODB.Connection")
strConnection="Data Source=xxxxxxx;"
con.Open strConnection

set rs = Server.CreateObject("ADODB.Recordset")
chartSQL="select ID,name,category_one from goods "
rs.Open chartSQL,con,1,3
if rs.EOF or rs.BOF then '如果为空
response.end
end if
pagesize=10 '每页显示10条记录
pagecuont=rs.PageCount '总页数
recordcount=rs.RecordCount
dim pagenum '当前页码
dim currentRecord '当前页的记录数,对于末页其值不等于pagesize
if Request.QueryString ("pageNum")="" then
pageNum=1
else
pageNum=Request.QueryString ("pageNum")
rs.AbsolutePage =trim(Request.QueryString ("pageNum"))
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
<SCRIPT LANGUAGE=javascript>
<!--
function openwindow(url){
window.open(url,'','resizable=no,width=240,height=160,fullscreen=yes')
}
//-->
</SCRIPT>
<link rel="stylesheet" href="file:///F|/mysourceof17560/CSS.CSS" type="text/css">
</head>
<body bgcolor=#999999>
<p align="center">商品修改页面</p>
<table border="1" width="100%" cellpadding="0" cellspacing="0" bordercolordark="#999999" bordercolorlight="#000000">
<tr>
<td width="10%">
<div align="center">编号 </div>
</td>
<td width="63%">
<div align="center">商品名 </div>
</td>
<td width="14%"> 
<div align="center">主分类</div>
</td>
<td width="13%">
<div align="center">操作 </div>
</td>
</tr>
<%
for i=1 to rs.PageSize
if rs.EOF or rs.BOF then '本条件判断是否到了尽头
exit for
end if
%>
<tr>
<td width="10%" align=center><%=rs("ID")%></td>
<td width="63%" align=center><%=rs("name")%> </td>
<td width="14%" align=center><%=rs("category_one")%> </td>
<td width="13%">
<div align="center">
<INPUT type="button" value="Button" id=button1 name=button1
onclick="javascript:window.open('tomodify.asp?id=<%=rs("ID")%>&zfenlei=<%=rs("category_one")%>','','resizable=no,width=240,height=160')">
 </div>
</td>
</tr>
<%
currentRecord=currentRecord+1 '取的当前页的记录数
rs.MoveNext
next
rs.Close
%>
</table>
<div align="center" class="bfont">合计<%=recordCount%> 条记录 | 第
<%
pageNum_record=(pageNum-1)*pageSize+1 '初始记录位置
pageNum_record_=pageNum_record+currentRecord-1 '末记录位置
Response.Write pageNum_record
%>
-<%=pageNum_record_%>条 | 第<%=pageNum%>页 |共<%=pagecuont%>页
<%
if pagecuont >0 then '防止当前返回的为空记录,即数据库中该数据集为空
if pageNum > 1 then %>
<a href="modifychart.asp?pageNum=1"> <font color="#FFFFFF">首页</font></a>
<%
else Response.Write "首页"
end if
if pageNum > 10 then
'如有需要,请在这里添上如果不足10页时该实现前n页的代码,
'请参考下面的如果后面不足10页时该怎么样处理的代码和思路
%>
<a href="modifychart.asp?pageNum=<%=(pageNum-10)%>"> <font color="#FFFFFF">前10页</font></a>
<%
end if
if (pageNum+10) < pagecuont then
'这里也相同参考下面的思路
%>
<a href="modifychart.asp?pageNum=<%=(pageNum+10)%>"> <font color="#FFFFFF">下10页</font></a>
<%
end if
if (pageNum+10) < pagecuont then
'这里判断后面是否还有10页
endpage=pageNum+9
else
endpage=pageCount
end if
for i=pageNum to endPage
%>
<a href="modifychart.asp?pageNum=<%=i%>">第<%=i%>页</a>
<%
next
if pageNum <> pageCount then
%>
<a href="modifychart.asp?pageNum=<%=pagecuont%>"> <font color="#FFFFFF">末页</font></a>
<%
end if
end if 'end of --->if pageCount >0 then
%>
</div>
</body>
</html>

slawdan
回复:

mm出马,色狼闻风而动~

underone
回复:

看来只能接分了

yhlovezx
回复:

不晓得楼上的接了分,我这还有没有剩的

sy_binbin
回复:

楼主,我还有50分就到2000分了!!

heroooooo
回复:

他们都给了,你看看能不能用,不能我给你写过.mm..呵呵..

amanda2002
回复:

好像不行,还有吗?

coder1
回复:

帮顶

bthl
回复:

DDDDDD

underone
回复:

此帖沦为色狼召集贴了

ice241018
回复:

MM发帖
群起而攻之
:)

atozxp
回复:

一页10条,我分了406页,sy_binbin(彬彬) 贴的那个代码好像在点击到第397页时就不再显示下面的页码了,仅有下列提示:
合计4056 条记录 | 第 4051 -4056条 | 第406页 |共406页 首页 前10页 末页

哪位还能再给完善完善?

taolixiang
回复:

小弟上次写了一个
rs.PageSize=10
rs.AbsolutePage=1
if request("page")<>"" then
rs.AbsolutePage=request("page")
end if
Dim pagenumber
pagenumber=20 '设置显示页码个数
If request("page")>0 then
pageid=CInt(Trim(request("page")))
End If
If pageid >pagenumber Then
If pageid Mod pagenumber=1 Then
x=pageid
ElseIf pageid Mod pagenumber=0 Then
x=pageid-(pagenumber-1)
Else
For a=1 To (pagenumber-2)
If pageid Mod pagenumber=a+1 Then
x=pageid-a
Exit For
end If
Next
End If
Else
x=1
End If
If rs.pagecount>=1 Then
For i=1 to rs.pagecount
For ii=x To x+(pagenumber-1)
If (ii Mod pagenumber)=1 And ii <> 1 Then
response.write "<a href="&request("script_name")&"?page="&ii-1&"><<</a>"
End If%>

<a href="<%=request("script_name")%>?page=<%=ii%>">&nbsp;<%=ii%></a>
<%
If ii Mod pagenumber=0 And ii <> 1 And ii<rs.pagecount Then
response.write "<a href="&request("script_name")&"?page="&ii+1&">&nbsp;>></a>"
End If
If ii>=rs.pagecount Then Exit for
Next
If i<ii Then Exit for
Next
End If
%>

rikcy
回复:

j=5*(i-1)+1
k=5*i
i用来控制点下上五页,下五页时变量控制,就象上一页,下一页那样简单
For j to k
Response.Write("<a href='****.asp?page="& j &"'>"& j &"</a>")
Next

mendel
回复:

Public Function GetPageList(curpage, PgCount, PageListNum, PageName)

'声明变量
Dim firstpage, endpage, lastpage, firststr, endstr, pagelist
Dim i,addpage

'判断参数是否正确
If Not IsNumeric(curpage) Or curpage = "" Or PgCount = "" Or Not IsNumeric(PgCount) Or PageListNum = "" Or Not IsNumeric(PageListNum) Or PageName = "" Then
Response.Write "<script language='javascript'>alert('在获取分页列表的时候发生错误!\n\n原因:参数不完整或类型错误!');</script>"
Exit Function
Response.End
End If
'判断页面
If LCase(Right(PageName, 4)) = ".asp" Then
PageName = PageName & "?"
Else
PageName = PageName & "&"
End If

'判断页数是否超出
If CLng(curpage) > CLng(pgcount) Then
curpage = 1
End If

firstpage=curpage-4
If Cint(firstpage)<1 then
firstpage=1
end if

endpage=curpage+4
if Cint(endpage)>Cint(pgcount) then
endpage=pgcount
end if
If endPage=0 Then endPage=1

'计算首页
If CLng(curpage) > 1 And CLng(pgcount) > 1 Then
firststr = "<a href='" & PageName & "Page=1' title='首页'><font face='Webdings'>9</font></a>&nbsp;"
End If

'计算前一个pagelistnum
If CLng(curpage) > CLng(PageListNum) Then
firststr =firststr& "<a href='" & PageName & "Page=" & curpage - PageListNum & "' title='前" & PageListNum & "页'><font face='Webdings'>7</font></a>&nbsp;"
End If

'计算前一页
If CLng(curpage) > 1 And CLng(pgcount) > 1 Then
firststr = firststr & "<a href='" & PageName & "Page=" & curpage - 1 & "' title='前一页'><font face='Webdings'>3</font></a>&nbsp;"
End If

'计算后一页
If CLng(curpage) < CLng(pgcount) And CLng(pgcount) > 1 Then
endstr = "<a href='" & PageName & "Page=" & curpage + 1 & "' title='后一页'><font face='Webdings'>4</font></a>&nbsp;"
End If

'计算后一个pagelistnum
If CLng(pgcount) - CLng(endpage) > 0 Then
If CLng(pgcount) - CLng(curpage) > CLng(PageListNum) Then
addpage = PageListNum
Else
addpage = CLng(pgcount) - CLng(endpage)
End If
endstr = endstr & "<a href='" & PageName & "Page=" & curpage + addpage & "' title='后" & PageListNum & "页'><font face='Webdings'>8</font></a>"
End If

If CLng(curpage) < CLng(pgcount) And CLng(pgcount) > 1 Then
endstr = endstr & "&nbsp;<a href='" & PageName & "Page=" & pgcount & "' title=""尾页""><font face=""Webdings"">:</font></a>&nbsp;"
End If


'获得循环页数
For i = firstpage To endpage
If CLng(i) = CLng(curpage) Then
pagelist = pagelist & "<font color=red><b>" & i & "</b></font>&nbsp;"
Else
pagelist = pagelist & "<a href='" & PageName & "Page=" & i & "' title='第" & i & "页'>" & i & "</a>&nbsp;"
End If
Next

'返回函数值
GetPageList = firststr & pagelist & endstr
End Function

mendel
回复:

curpage 当前页
PgCount 总页数
PageListNum=显示多少条页数
PageName传递过来的页面名称,可以带参数

xiaofanku
回复:

to:sy_binbin(彬彬)

去回答我的问题!你还多50分!

rkismet
回复:

呵呵,这个问题有一定的技术含量吗,呵呵,不过并不难,
单做一个分页函数,专门用来生成这一行显示的就可以了,里面的基本实现是先判断当前所在页的位置,然后分别加五和减五,看其所在的是在哪个五位数之死,分别以12345,678910,1112131415,这样分,让他mod五就可以分清楚了,呵呵,这样就可以实现了,这只是基本思想,具体实现,自己再研究一下吧


相关文章
html如何轉成pdf?
如何显示、隐藏指定的层
sqldatasource字段问题
链接问题!
update的数据只能是数字,为什么呢?
大家帮我看这,为什么这里无法添加新闻内容呢?
做了个日文版的网页,我用的中文编码的,这样会有问题吗?大家来测试
大家帮忙看看这个程序有上传漏洞么,谢谢!
vbscript中调用javascript函数出错????????????
请问大家ASP如何访问 .dbf 的数据库文件,帮我看看下面的代码有什么问题?
高手帮忙!!急!谢谢!!代码解释!
在线影院网站涉及技术请教!
热门文章
输入地址时http://192.168.01/default.asp能正常使用,但是用http://192.168.0.1/则只能显示首页
请问如何给select控件赋值,让他指定跳到某一个值。在线等
请高手帮解密
关于asp的server.URLEncode()后如何得到utf-8的问题
如何将文件保存为UTF8格式
由于该控件目前不可见、未启用或其类型不允许,因此无法将焦点移向它。
哪位大哥大姐能详细的说说关于“WinHttp.WinHttpRequest”组件的使用啊?
如何用javascript做表单验证程序.
如何实现选择下拉菜单后在文本框中显示相应的值
ASP导入Excel数据
http/1.1 503 Service Unavailable
网页打印,如何自动去除页眉页脚!!!

编程社区 2008 浙ICP备09013498号
© TinyBBS.cn
编程好站连接:codeproject sf.net codeplex