明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

怎么用ASP完成分頁(一)

[摘要]<%@ Language=VBScript %> <HTML> <HEAD> </HEAD> <BODY> <% dim currentpage '定義當(dāng)前頁 dim filename '文件名 Const MaxP...

<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>

<%
dim currentpage '定義當(dāng)前頁
dim filename '文件名
Const MaxPerPage=20 '每頁顯示的記錄個(gè)數(shù)
dim totalnumber '記錄總數(shù)
filename="showpages.asp"
totalnumber=200 '設(shè)置記錄總數(shù)為200

if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
showpages totalnumber,MaxPerPage,filename
%>
</BODY>
</HTML>
<%'定義分頁的函數(shù),以totalnumber,maxperpage,filename作為函數(shù)的入口。
function showpages(totalnumber,maxperpage,filename)
dim n
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
response.write "<form method=Post action="&filename&">"
response.write "<p align='center'>記錄分頁&nbsp;"
if CurrentPage<2 then
response.write "<font color='999966'>首頁 上一頁</font>&nbsp;"
else
response.write "<a href="&filename&"?page=1>首頁</a>&nbsp;"
response.write "<a href="&filename&"?page="&CurrentPage-1&">上一頁</a>&nbsp;"
end if
if n-currentpage<1 then
response.write "<font color='999966'>下一頁 尾頁</font>"
else
response.write "<a href="&filename&"?page="&(CurrentPage+1)
response.write ">下一頁</a> <a href="&filename&"?page="&n&">尾頁</a>"
end if
response.write "&nbsp;頁次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>頁 &nbsp;"
response.write " 轉(zhuǎn)到:<input type='text' name='page' size=4 maxlength=10 class=smallInput

value="&currentpage&">"
response.write "<input class=buttonface type='submit' value=' Goto ' name='cndok'></span></p></form>"

end function
%>
(出處:熱點(diǎn)網(wǎng)絡(luò))