asp 分页码 做出像百度似的分页码

来源:百度知道 编辑:UC知道 时间:2024/06/17 19:02:59
<%
counter = 0
For i = 1 to au_total Step size
counter = counter + 1
PageEndCount = i + size - 1
if PageEndCount > au_total Then PageEndCount = au_total
if i <> offset + 1 then
Response.Write("<a href=""" & Request.ServerVariables("URL") & "?" & keepMove & "offset=" & i-1 & """>")
Response.Write(counter & "</a>")
else
Response.Write("<b><font color='#FFFFFF'>" & counter & "</font></b>")
End if
next
%>
光是这样的话页码就都显出来了...

你把我的代码中的page换成你代码中的表示当前页的变量就行了
<%
'page为当前页的码
'从当前页减counts到当前页加counts
'百度的为前9页到后9页
dim counts,totalPages
counts=9
totalPages=rs.recordcount

call ShowPages (totalPages,counts)

'以下为显示页码过程
Sub ShowPages(totalPages,counts)
for j=page-counts to page
if j>0 then
if j=page then
response.Write("<b>"&j&"</b> ")'
else
response.Write("<a href=?page="&j&">"&j&"</a> ")
end if
end if
next

for j=page+1 to page+counts
if j<totalPages-9 then
response.Write("<a href=?page="&j&">"&j&"</a> ")
end if
next
end sub
%>

if j>0 then
if j=page then
response.Write("<b>"&j&"</b> ")'
else
response.Write("&l