ASP分頁程序的詳細(xì)說明
本文主要給大家介紹到的是關(guān)于ASP分頁程序的詳細(xì)解析,希望能給大家?guī)韼椭騿l(fā)。
<!--#include virtual="/share/config.asp"-->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
td {
font-size: 12px;
}
-->
</style>
</head>
<center>
<body>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<form name="form1" method="post" action="showpage_test.asp">
<tr>
<td width="112" height="20"><div align="center">起始日期</div></td>
<td width="288" height="20"><input name="startTime" type="text" id="startTime" onClick="setday(this)" size="20" readonly></td>
</tr>
<tr>
<td height="20"><div align="center">結(jié)束日期</div></td>
<td height="20"><input name="endTime" type="text" id="endTime" onClick="setday(this)" size="20" readonly></td>
</tr>
<tr>
<td height="20" colspan="2"><div align="center">
<input type="submit" name="Submit" value="查詢">
<input type="submit" name="Submit2" value="我要投訴">
</div></td>
</tr>
</form>
</table>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<%
const MaxPerPage=1
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j
if request("page")="" then
currentPage=1
else
currentPage=cint(request("page"))'在表單中先強制只能輸入數(shù)字
'if IsNumeric(request("page")) then
'currentPage=cint(request("page"))
'else
'Response.write "這里提示只能輸入數(shù)字"
'end if
end if
%>
<%
Set Conn=Server.CreateObject("adodb.Connection")
Conn.Open Application("connStr")
Set Rs=server.createobject("adodb.recordset")
startTime=request("startTime")
endTime=request("endTime")
if startTime<>"" and endTime<>"" then
endTime=dateadd("d",1,endTime)
sql="select * from d_leave_word where ly_Date between '"&startTime&"' and '"&endTime&"'"
endTime=dateadd("d",-1,endTime)
else
sql="select * from d_leave_word"
end if
GoPage="showpage_test.asp"
Condition="&startTime="&startTime&"&endTime="&endTime&""
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<p align='center'><font color='#000066'>還沒任何信息!</font></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,GoPage
elseif (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,GoPage
else
currentPage=1
showContent
showpage totalput,MaxPerPage,GoPage
end if
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<%
sub showContent
dim i
i=0
%>
<table width="96%" border="0" cellpadding="0" cellspacing="1" bgcolor="#4D90AB">
<tr bgcolor="#D7F3FF">
<td width="80" height="21"><div align="center">投訴類別</div></td>
<td width="124" height="21"><div align="center">投訴內(nèi)容</div></td>
<td width="60" height="21"><div align="center">投訴日期</div></td>
<td width="60" height="21"><div align="center">投訴狀態(tài)</div></td>
<td width="127" height="21"><div align="center">處理意見</div></td>
<td width="60" height="21"><div align="center">處理時間</div></td>
<td width="40"><div align="center">查看</div></td>
</tr>
<%do while not rs.eof%>
<tr bgcolor="#FFFFFF">
<td width="80" height="20"><div align="center"><%=HTMLdecode(rs("Type_Name"))%></div></td>
<td height="20"><div align="left">
<%if len(HTMLdecode(rs("Content")))>9 then response.write left(HTMLdecode(rs("Content")),9)&"..." else response.write HTMLdecode(rs("Content")) end if%>
</div></td>
<td width="60" height="20"><div align="center"><%=rs("ly_Date")%></div></td>
<td width="60" height="20"><div align="center">
<%if HTMLdecode(rs("Re_Content"))<>"" then response.write "已回復(fù)" else response.write "處理中" end if%>
</div></td>
<td height="20"><div align="left">
<%if len(rs("Re_Content"))>9 then response.write left(rs("Re_Content"),9)&"..." else response.write rs("Re_Content") end if%>
</div></td>
<td width="60" height="20"><div align="center"><%=HTMLdecode(rs("Re_Date"))%></div></td>
<td width="40"><div align="center"><a href="leave_word.asp?sType=查看&id=<%=rs("id")%>">查看</a></div></td>
</tr>
<%i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop%>
</table>
<%end sub%>
</div></td>
</tr>
</table>
</body></center>
</html>
<%
function showpage(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='"&GoPage&"?z=1"&Condition&"'>"
' response.write "<p align='left' vAlign='bottom'> >>信息分頁 "
response.write "<p align='center' vAlign='center'> "
if CurrentPage<2 then
response.write "<font color='#648ECE'>首頁 上一頁</font> "
else
response.write "<a href="&filename&"?page=1"&Condition&">首頁</a> "
response.write "<a href="&filename&"?page="&CurrentPage-1&""&Condition&">上一頁</a> "
end if
if n-currentpage<1 then
response.write "<font color='#648ECE'>下一頁 尾頁</font>"
else
response.write "<a href="&filename&"?page="&CurrentPage+1&""&Condition&">下一頁</a> "
response.write "<a href="&filename&"?page="&n&""&Condition&">尾頁</a>"
end if
response.write " 頁次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>頁 "
response.write " 共<b>"&totalnumber&"</b>個信息 <b>"&maxperpage&"</b>個信息/頁 "
response.write " 轉(zhuǎn)到:<input class=TextBorder style='FONT-SIZE:8pt;width:20;HEIGHT:18px;' type='text' name='page' size=2 maxlength=10 class=smallInput value="¤tpage&" onkeydown='onlyNum();'>"
response.write " <input name='submit' type='submit' value='提交'>"
response.write "</span></p></form>"
end function
%>
<script language=java script>
function onlyNum()
{if(!((event.keyCode>=48&&event.keyCode<=57)||(event.keyCode>=96&&event.keyCode<=105)))
event.returnValue=false;}
</script>
<!-- <script language="java script" src="...js"></script> 用來調(diào)用JS文件-->
<script language="java script">
<!--