1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

完美分页程序代码!!!!

本帖由 blackearth2006-12-01 发布。版面名称:源码讨论

  1. blackearth

    blackearth New Member

    注册:
    2006-09-13
    帖子:
    154
    赞:
    0
    <%
    Dim SqlStr,Page_Value,Page_Value_Max,Permsg,itemStr,Rs,Count,item
    SqlStr = ""
    if IsNumeric(Request("Page_Value")) or Request("Page_Value") = "" then
    if IsNumeric(Request("Page_Value_Max")) or Request("Page_Value_Max") = "" then
    Page_Value=Request("Page_Value")
    Page_Value_Max=Request("Page_Value_Max")
    PerMsg = 20
    if Page_Value = "" then
    Page_Value = 1
    Else
    Page_Value = Cint(Page_Value)
    end if
    If Page_Value<1 Or Page_Value="" then
    Page_Value=1
    End If
    if Page_Value_Max = "" then
    Page_Value_Max = 1
    Else
    Page_Value_Max = Cint(Page_Value_Max)
    end if
    if Page_Value <= Page_Value_Max then
    Set Rs=Server.createobject("Adodb.Recordset")
    Rs.Open SqlStr,Conn,1,1
    if Not Rs.Bof And Not Rs.Eof then
    Rs.Pagesize=Permsg
    Count=Page_Value*Rs.PageSize
    Rs.AbsolutePosition=Count-Rs.PageSize+1
    Page_Value_Max = Rs.PageCount
    Do While Not Rs.Eof And Permsg>0
    %>
    Html
    <%
    Permsg = Permsg - 1
    Rs.Movenext
    Loop
    itemStr = ""
    For Each item in Request.Form
    if item <> "Page_Value" And item <> "Page_Value_Max" then
    itemStr = itemStr & "&" & item & "=" & Server.HTMLEncode(Request.Form(item))
    End if
    Next
    if itemStr = "" then
    For Each item in Request.QueryString
    if item <> "Page_Value" And item <> "Page_Value_Max" then
    itemStr = itemStr & "&" & item & "=" & Server.HTMLEncode(Request.QueryString(item))
    End if
    Next
    End if
    %>


    <form name="Page_Value_Form" method="POST" action="<%=Request.ServerVariables("URL")%>?Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>">共<b><font color="#FF0000"><%=Rs.RecordCount%></font></b>条 <b><font color="#FF0000"><%=Page_Value%>/<%=Page_Value_Max%></font></b> <a href="javascript:Next_Or_Previous_Value_Page(1)">首页</a> <a href="javascript:Next_Or_Previous_Value_Page(2)">上一页</a> <a href="javascript:Next_Or_Previous_Value_Page(3)">下一页</a> <a href="javascript:Next_Or_Previous_Value_Page(4)">末页</a> <input type="submit" value="转到"> <input type="text" name="Page_Value" size="3">页</form>


    <script language="JavaScript">
    function Next_Or_Previous_Value_Page(vChar){
    if(vChar == 1)location.href="<%=Request.ServerVariables("URL")%>?Page_Value=1&Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>";
    if(vChar == 2)location.href="<%=Request.ServerVariables("URL")%>?Page_Value=<%if Page_Value - 1 = 0 then Response.Write 1 Else Response.Write Page_Value - 1 end if%>&Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>";
    if(vChar == 3)location.href="<%=Request.ServerVariables("URL")%>?Page_Value=<%if Page_Value + 1 >= Page_Value_Max then Response.Write Page_Value_Max Else Response.Write Page_Value + 1 end if%>&Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>";
    if(vChar == 4)location.href="<%=Request.ServerVariables("URL")%>?Page_Value=<%=Page_Value_Max%>&Page_Value_Max=<%=Page_Value_Max%><%=itemStr%>";
    }
    </script>

    <%
    Else
    Response.Write "<tr><td><center>无您所需的内容</center></td></tr>"
    End if
    Rs.Close
    Set Rs = Nothing
    Else
    Response.Write("<script>alert('输入的值超过最大页,点击确定返回');history.back()</script>")
    End if
    Else
    Response.Write("<script>alert('非法请求,点击确定返回');history.back()</script>")
    End if
    Else
    Response.Write("<script>alert('非法请求,点击确定返回');history.back()</script>")
    End if
    %>
     
  2. hotlt

    hotlt New Member

    注册:
    2006-10-23
    帖子:
    19
    赞:
    2
    有演示没,或者图片
     
  3. 西子宜

    西子宜 Well-Known Member

    注册:
    2005-09-05
    帖子:
    15,739
    赞:
    62
    这个程序好