程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> ShowPage 顯示“上一頁 下一頁”等信息的封裝代碼

ShowPage 顯示“上一頁 下一頁”等信息的封裝代碼

編輯:關於ASP編程
'**************************************************
'函數名:ShowPage
'作  用:顯示“上一頁 下一頁”等信息
'參  數:sFileName  ----鏈接地址
'       TotalNumber ----總數量
'       MaxPerPage  ----每頁數量
'       ShowTotal   ----是否顯示總數量
'       ShowAllPages ---是否用下拉列表顯示所有頁面以供跳轉。有某些頁面不能使用,否則會出現JS錯誤。
'       strUnit     ----計數單位
'返回值:“上一頁 下一頁”等信息的HTML代碼
'**************************************************
function ShowPage(sFileName,TotalNumber,MaxPerPage,ShowTotal,ShowAllPages,strUnit)
    dim TotalPage,strTemp,strUrl,i

    if TotalNumber=0 or MaxPerPage=0 or isNull(MaxPerPage) then
        ShowPage=""
        exit function
    end if
    if totalnumber mod maxperpage=0 then
        TotalPage= totalnumber \ maxperpage
      Else
        TotalPage= totalnumber \ maxperpage+1
      end if
    if CurrentPage>TotalPage then CurrentPage=TotalPage

      strTemp= "<table align='center'><tr><td>"
    if ShowTotal=true then 
        strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "  "
    end if
    strUrl=JoinChar(sfilename)
      if CurrentPage<2 then
        strTemp=strTemp & "首頁 上一頁 "
      Else
        strTemp=strTemp & "<a href='" & strUrl & "page=1'>首頁</a> "
        strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上一頁</a> "
      end if

      if CurrentPage>=TotalPage then
        strTemp=strTemp & "下一頁 尾頁"
      Else
        strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一頁</a> "
        strTemp=strTemp & "<a href='" & strUrl & "page=" & TotalPage & "'>尾頁</a>"
      end if
       strTemp=strTemp & " 頁次:<strong><font color=red>" & CurrentPage & "</font>/" & TotalPage & "</strong>頁 "
        strTemp=strTemp & " <b>" & maxperpage & "</b>" & strUnit & "/頁"
    if ShowAllPages=True then
        strTemp=strTemp & "  轉到第<input type='text' name='page' size='3' maxlength='5' value='" & CurrentPage & "' onKeyPress=""if (event.keyCode==13) window.location='" & strUrl & "page=" & "'+this.value;""'>頁"
         'strTemp  = strTemp &" <Input type=""button""  onClick=""window.location.href='" & strUrl & "page='+document.all.page.value;""  name=button1  value=GO >"
    end if
    strTemp=strTemp & "</td></tr></table>"
    ShowPage=strTemp
end function
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved