<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
dim currentpage '定义当前页
dim filename '文件名
Const MaxPerPage=20 '每页显示的记录个数
dim totalnumber '记录总数
filename="showpages.asp"
totalnumber=200 '设置记录总数为200
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
showpages totalnumber,MaxPerPage,filename
%>
</BODY>
</HTML>
<%'定义分页的函数,以totalnumber,maxperpage,filename作为函数的入口。
function showpages()
dim n
if (totalnumber mod MaxPerPage)=0 then
n= totalPut / MaxPerPage
else
n= totalPut / MaxPerPage + 1
end if
if n=1 then
exit sub
end if
dim k
response.write "<p align='left'>>> 分页 "
for k=1 to n
if k=currentPage then
response.write "[<b>"+Cstr(k)+"</b>] "
else
response.write "[<b>"+"<a href="&filename&"?page="+cstr(k)+">"+Cstr(k)+"</a></b>] "
end if
next
response.write "</p>"
end function
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
dim currentpage '定义当前页
dim filename '文件名
Const MaxPerPage=20 '每页显示的记录个数
dim totalnumber '记录总数
filename="showpages.asp"
totalnumber=200 '设置记录总数为200
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
showpages totalnumber,MaxPerPage,filename
%>
</BODY>
</HTML>
<%'定义分页的函数,以totalnumber,maxperpage,filename作为函数的入口。
function showpages()
dim n
if (totalnumber mod MaxPerPage)=0 then
n= totalPut / MaxPerPage
else
n= totalPut / MaxPerPage + 1
end if
if n=1 then
exit sub
end if
dim k
response.write "<p align='left'>>> 分页 "
for k=1 to n
if k=currentPage then
response.write "[<b>"+Cstr(k)+"</b>] "
else
response.write "[<b>"+"<a href="&filename&"?page="+cstr(k)+">"+Cstr(k)+"</a></b>] "
end if
next
response.write "</p>"
end function
%>