当前位置:首页文章首页 IT学院 IT技术

ASP分页程序的详细说明

作者:  来源:  发布时间:2011-6-11 11:48:34  点击:

 本文主要给大家介绍到的是关于ASP分页程序的详细解析,希望能给大家带来帮助或启发。

<!--#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">结束日期</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"))'在表单中先强制只能输入数字
 'if IsNumeric(request("page")) then
  'currentPage=cint(request("page"))
 'else
 'Response.write "这里提示只能输入数字"
 '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">投诉内容</div></td>
              <td width="60" height="21"><div align="center">投诉日期</div></td>
              <td width="60" height="21"><div align="center">投诉状态</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 "已回复" 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'>&nbsp;&nbsp;&gt;&gt;信息分页&nbsp;"
response.write "<p align='center' vAlign='center'>&nbsp;&nbsp;"
if CurrentPage<2 then
 response.write "<font color='#648ECE'>首页 上一页</font>&nbsp;"
else
 response.write "<a href="&filename&"?page=1"&Condition&">首页</a>&nbsp;"
 response.write "<a href="&filename&"?page="&CurrentPage-1&""&Condition&">上一页</a>&nbsp;"
end if
if n-currentpage<1 then
 response.write "<font color='#648ECE'>下一页 尾页</font>"
else
 response.write "<a href="&filename&"?page="&CurrentPage+1&""&Condition&">下一页</a>&nbsp;"
 response.write "<a href="&filename&"?page="&n&""&Condition&">尾页</a>"
end if
response.write "&nbsp;页次:<strong><font color=red>"&CurrentPage&"</font>/"&n&"</strong>页 "
response.write "&nbsp;共<b>"&totalnumber&"</b>个信息 <b>"&maxperpage&"</b>个信息/页 "
response.write "&nbsp;转到:<input class=TextBorder style='FONT-SIZE:8pt;width:20;HEIGHT:18px;' type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&" onkeydown='onlyNum();'>"
response.write "&nbsp;&nbsp;<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>  用来调用JS文件-->
<script language="java script">
<!--

首页 上一页 [1] [2] [3] [4] [5]  下一页 尾页

相关软件

相关文章

文章评论

软件按字母排列: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z