asp 分頁程式

來源:互聯網
上載者:User

'過程名:showpage
'作  用:顯示“上一頁 下一頁”等資訊
'參  數:sfilename  ----連結地址
'       totalnumber ----總數量
'       maxperpage  ----每頁數量
'       ShowTotal   ----是否顯示總數量
'       ShowAllPages ---是否用下拉式清單顯示所有頁面以供跳轉。有某些頁面不能使用,否則會出現JS錯誤。
'       strUnit     ----計數單位
'***********************************************
sub showpage(sfilename,totalnumber,maxperpage,ShowTotal,ShowAllPages,strUnit)
 dim n, i,strTemp,strUrl
 if totalnumber mod maxperpage=0 then
     n= totalnumber maxperpage
   else
     n= totalnumber maxperpage+1
   end if
   strTemp= "<table align='center'><form name='showpages' method='Post' action='" & sfilename & "'><tr><td>"
 if ShowTotal=true then
  strTemp=strTemp & "共 <b>" & totalnumber & "</b> " & strUnit & "&nbsp;&nbsp;"
 end if
 strUrl=JoinChar(sfilename)
   if CurrentPage<2 then
      strTemp=strTemp & "首頁 上一頁&nbsp;"
   else
      strTemp=strTemp & "<a href='" & strUrl & "page=1'>首頁</a>&nbsp;"
      strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage-1) & "'>上一頁</a>&nbsp;"
   end if

   if n-currentpage<1 then
      strTemp=strTemp & "下一頁 尾頁"
   else
      strTemp=strTemp & "<a href='" & strUrl & "page=" & (CurrentPage+1) & "'>下一頁</a>&nbsp;"
      strTemp=strTemp & "<a href='" & strUrl & "page=" & n & "'>尾頁</a>"
   end if
    strTemp=strTemp & "&nbsp;頁次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>頁 "
    strTemp=strTemp & "&nbsp;<b>" & maxperpage & "</b>" & strUnit & "/頁"
 if ShowAllPages=True then
  strTemp=strTemp & "&nbsp;轉到:<select name='page' size='1' onchange='javascript:submit()'>"  
     for i = 1 to n  
      strTemp=strTemp & "<option value='" & i & "'"
   if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
   strTemp=strTemp & ">第" & i & "頁</option>"  
     next
  strTemp=strTemp & "</select>"
 end if
 strTemp=strTemp & "</td></tr></form></table>"
 response.write strTemp
end sub

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.