分页的解析处理(ASP)
2004-08-03 15:37
323 查看
<%@ Language = VBScript %>
<% Option Explicit %>
<script language="javascript">
function fPageClick(pageno){
var url = ''
url = 'page.asp' +
'?crtpage=' + pageno
document.location.replace(url);
}
</script>
<%
Const GSTR_DIS_FVLH_TTL_BACK = "<<前へ"
Const GSTR_DIS_FVLH_TTL_FWRD = "次へ>>"
'==========================================================
'機能 : 表示用ページ番号解析処理
'引数 : なし
' total IN 全ページ数
' current IN カレントのページ
' dispnum IN 中央表示ページ数 ※ 奇数
' amari IN 余りページ表示数 指定数に大体近い数が採用される
' aryPagesL OUT 左ページ番号の配列
' aryPagesM OUT 中央ページ番号の配列
' aryPagesR OUT 右ページ番号の配列
' jmpL OUT 左ジャンプ数
' jmpR OUT 右ジャンプ数
'返却値 : なし
'==========================================================
Function fblnGetArrayOfManyPages(ByVal total, ByVal current, ByVal dispnum, ByVal amari, ByRef aryPagesL, ByRef aryPagesM, ByRef aryPagesR, ByRef jmpL, ByRef jmpR)
Dim currentL, currentR 'カレント5件の左右のページ番号
Dim lenL, lenR 'カレント左右の残り件数
Dim sepL, sepR '左右のジャンプ間隔
Dim viewL, viewR '左右の実表示個数
fblnGetArrayOfManyPages = False
If current > total Or current < 1 Then Exit Function
If total <= 0 Then Exit Function
If dispnum <= 0 Then Exit Function
If dispnum / 2 = Int(dispnum / 2) Then Exit Function
If amari <= 0 Then Exit Function
currentL = current - Int(dispnum / 2)
If currentL <= 2 Then
currentL = 1
currentR = dispnum
Else
currentR = current + Int(dispnum / 2)
If currentR >= total - 3 Then
currentL = total - dispnum
currentR = total
End If
End If
If total <= dispnum Then
currentL = 1
currentR = total
End If
lenL = currentL - 1
lenR = total - currentR
If lenL <= 0 Then
viewL = 1
Else
viewL = Round(amari * lenL / (lenL +lenR), 0)
End If
If lenR <= 0 Then
viewR = total
Else
viewR = Round(amari * lenR / (lenL +lenR), 0)
End If
sepL = 0
sepR = 0
If viewL > 0 Then
sepL = Round(LenL / viewL, 0)
If sepL < 1 Then sepL = 1
End If
If viewR > 0 Then
sepR = Round(LenR / viewR, 0)
If sepR < 1 Then sepR = 1
End If
'ページ配列の生成
Dim intPagesL, intPagesM, intPagesR
Dim i
intPagesL = 0
If sepL > 0 Then
For i = 1 To currentL Step sepL
If i >= currentL Then Exit For
If Not IsArray(aryPagesL) Then aryPagesL = Array(-1)
ReDim Preserve aryPagesL(intPagesL)
aryPagesL(intPagesL) = i
intPagesL = intPagesL + 1
Next
Else
If currentL > 1 Then
If Not IsArray(aryPagesL) Then aryPagesL = Array(-1)
ReDim Preserve aryPagesL(intPagesL)
aryPagesL(intPagesL) = 1
End If
End If
intPagesM = 0
For i = currentL To currentR
If Not IsArray(aryPagesM) Then aryPagesM = Array(-1)
ReDim Preserve aryPagesM(intPagesM)
aryPagesM(intPagesM) = i
intPagesM = intPagesM + 1
Next
If total > currentR Then
intPagesR = 0
If sepR > 0 Then
For i = currentR + sepR To total Step sepR
If i >= total Then
' If intPagesR > 0 Then
' intPagesR = intPagesR - 1
' End If
Exit For
End If
If Not IsArray(aryPagesR) Then aryPagesR = Array(-1)
ReDim Preserve aryPagesR(intPagesR)
aryPagesR(intPagesR) = i
intPagesR = intPagesR + 1
Next
End If
If Not IsArray(aryPagesR) Then aryPagesR = Array(-1)
ReDim Preserve aryPagesR(intPagesR)
aryPagesR(intPagesR) = total
End If
jmpL = sepL
jmpR = sepR
fblnGetArrayOfManyPages = True
End Function
Function fGetPageHTML(strHTML,totalPage,currentPage,dispnum,amari)
Dim aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR, i, intTempPage
'If fblnGetArrayOfManyPages(lngPageNumber, lngCurentPage, 5, 6, aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR) Then
If fblnGetArrayOfManyPages(totalPage, currentPage, dispnum, amari, aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR) Then
Dim strDisp, strDelmiL, strDelmiR
If currentPage = 1 Then
strHTML = strHTML & GSTR_DIS_FVLH_TTL_BACK & " "
Else
strHTML = strHTML & "<a href=javascript:fPageClick(" & currentPage-1 & ")>" & GSTR_DIS_FVLH_TTL_BACK & "</a> "
End If
'## 実ページ番号の表示部分
strDelmiL = "…"
strDelmiR = "…"
If jmpL <= 1 Then
strDelmiL = " "
End If
If jmpR <= 1 Then
strDelmiR = " "
End If
If IsArray(aryPagesL) Then
intTempPage = CInt(-100)
For i = 0 To UBound(aryPagesL)
If (intTempPage + 1) < CInt(aryPagesL(i)) Then
strHTML = strHTML & "<a href=javascript:fPageClick(" & CStr(aryPagesL(i)) & ")>" & CStr(aryPagesL(i)) & "</a>" & strDelmiL
intTempPage = CInt(aryPagesL(i))
End If
Next
End If
If IsArray(aryPagesM) Then
For i = 0 To UBound(aryPagesM)
If Int(aryPagesM(i)) = Int(currentPage) Then
strHTML = strHTML & "<b>[" & CStr(aryPagesM(i)) & "]</b>"
Else
strHTML = strHTML & "<a href=javascript:fPageClick(" & CStr(aryPagesM(i)) & ")>" & CStr(aryPagesM(i)) & "</a>"
End If
If i <> UBound(aryPagesM) Then
strHTML = strHTML & " "
End If
Next
End If
If IsArray(aryPagesR) Then
Dim strHTMLWork : strHTMLWork = ""
intTempPage = CInt(aryPagesR(UBound(aryPagesR))) + 100
For i = UBound(aryPagesR) To 0 Step -1
If (intTempPage - 1) > CInt(aryPagesR(i)) Then
strHTMLWork = strDelmiR & "<a href=javascript:fPageClick(" & CStr(aryPagesR(i)) & ")>" & CStr(aryPagesR(i)) & "</a>" & strHTMLWork
intTempPage = CInt(aryPagesR(i))
End If
Next
strHTML = strHTML & strHTMLWork
End If
'## 「次へ>>」の表示部分
If Int(currentPage) = Int(currentPage) Then
strHTML = strHTML & " " & GSTR_DIS_FVLH_TTL_FWRD & "</td>"
Else
strHTML = strHTML & " <a href=javascript:fPageClick(" & currentPage+1 & ")>" & GSTR_DIS_FVLH_TTL_FWRD & "</a></td>"
End If
Else
strHTML = strHTML & ""
End If
End Function
Dim lngCurentPage
Dim strHTML
Dim blnRet
If Request.QueryString("crtpage")<>"" Then
lngCurentPage = CLng(Request.QueryString("crtpage"))
Else
lngCurentPage = 1
End If
blnRet = fGetPageHTML(strHTML,1000,lngCurentPage,5,6)
response.write(strHTML)
%>
<% Option Explicit %>
<script language="javascript">
function fPageClick(pageno){
var url = ''
url = 'page.asp' +
'?crtpage=' + pageno
document.location.replace(url);
}
</script>
<%
Const GSTR_DIS_FVLH_TTL_BACK = "<<前へ"
Const GSTR_DIS_FVLH_TTL_FWRD = "次へ>>"
'==========================================================
'機能 : 表示用ページ番号解析処理
'引数 : なし
' total IN 全ページ数
' current IN カレントのページ
' dispnum IN 中央表示ページ数 ※ 奇数
' amari IN 余りページ表示数 指定数に大体近い数が採用される
' aryPagesL OUT 左ページ番号の配列
' aryPagesM OUT 中央ページ番号の配列
' aryPagesR OUT 右ページ番号の配列
' jmpL OUT 左ジャンプ数
' jmpR OUT 右ジャンプ数
'返却値 : なし
'==========================================================
Function fblnGetArrayOfManyPages(ByVal total, ByVal current, ByVal dispnum, ByVal amari, ByRef aryPagesL, ByRef aryPagesM, ByRef aryPagesR, ByRef jmpL, ByRef jmpR)
Dim currentL, currentR 'カレント5件の左右のページ番号
Dim lenL, lenR 'カレント左右の残り件数
Dim sepL, sepR '左右のジャンプ間隔
Dim viewL, viewR '左右の実表示個数
fblnGetArrayOfManyPages = False
If current > total Or current < 1 Then Exit Function
If total <= 0 Then Exit Function
If dispnum <= 0 Then Exit Function
If dispnum / 2 = Int(dispnum / 2) Then Exit Function
If amari <= 0 Then Exit Function
currentL = current - Int(dispnum / 2)
If currentL <= 2 Then
currentL = 1
currentR = dispnum
Else
currentR = current + Int(dispnum / 2)
If currentR >= total - 3 Then
currentL = total - dispnum
currentR = total
End If
End If
If total <= dispnum Then
currentL = 1
currentR = total
End If
lenL = currentL - 1
lenR = total - currentR
If lenL <= 0 Then
viewL = 1
Else
viewL = Round(amari * lenL / (lenL +lenR), 0)
End If
If lenR <= 0 Then
viewR = total
Else
viewR = Round(amari * lenR / (lenL +lenR), 0)
End If
sepL = 0
sepR = 0
If viewL > 0 Then
sepL = Round(LenL / viewL, 0)
If sepL < 1 Then sepL = 1
End If
If viewR > 0 Then
sepR = Round(LenR / viewR, 0)
If sepR < 1 Then sepR = 1
End If
'ページ配列の生成
Dim intPagesL, intPagesM, intPagesR
Dim i
intPagesL = 0
If sepL > 0 Then
For i = 1 To currentL Step sepL
If i >= currentL Then Exit For
If Not IsArray(aryPagesL) Then aryPagesL = Array(-1)
ReDim Preserve aryPagesL(intPagesL)
aryPagesL(intPagesL) = i
intPagesL = intPagesL + 1
Next
Else
If currentL > 1 Then
If Not IsArray(aryPagesL) Then aryPagesL = Array(-1)
ReDim Preserve aryPagesL(intPagesL)
aryPagesL(intPagesL) = 1
End If
End If
intPagesM = 0
For i = currentL To currentR
If Not IsArray(aryPagesM) Then aryPagesM = Array(-1)
ReDim Preserve aryPagesM(intPagesM)
aryPagesM(intPagesM) = i
intPagesM = intPagesM + 1
Next
If total > currentR Then
intPagesR = 0
If sepR > 0 Then
For i = currentR + sepR To total Step sepR
If i >= total Then
' If intPagesR > 0 Then
' intPagesR = intPagesR - 1
' End If
Exit For
End If
If Not IsArray(aryPagesR) Then aryPagesR = Array(-1)
ReDim Preserve aryPagesR(intPagesR)
aryPagesR(intPagesR) = i
intPagesR = intPagesR + 1
Next
End If
If Not IsArray(aryPagesR) Then aryPagesR = Array(-1)
ReDim Preserve aryPagesR(intPagesR)
aryPagesR(intPagesR) = total
End If
jmpL = sepL
jmpR = sepR
fblnGetArrayOfManyPages = True
End Function
Function fGetPageHTML(strHTML,totalPage,currentPage,dispnum,amari)
Dim aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR, i, intTempPage
'If fblnGetArrayOfManyPages(lngPageNumber, lngCurentPage, 5, 6, aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR) Then
If fblnGetArrayOfManyPages(totalPage, currentPage, dispnum, amari, aryPagesL, aryPagesM, aryPagesR, jmpL, jmpR) Then
Dim strDisp, strDelmiL, strDelmiR
If currentPage = 1 Then
strHTML = strHTML & GSTR_DIS_FVLH_TTL_BACK & " "
Else
strHTML = strHTML & "<a href=javascript:fPageClick(" & currentPage-1 & ")>" & GSTR_DIS_FVLH_TTL_BACK & "</a> "
End If
'## 実ページ番号の表示部分
strDelmiL = "…"
strDelmiR = "…"
If jmpL <= 1 Then
strDelmiL = " "
End If
If jmpR <= 1 Then
strDelmiR = " "
End If
If IsArray(aryPagesL) Then
intTempPage = CInt(-100)
For i = 0 To UBound(aryPagesL)
If (intTempPage + 1) < CInt(aryPagesL(i)) Then
strHTML = strHTML & "<a href=javascript:fPageClick(" & CStr(aryPagesL(i)) & ")>" & CStr(aryPagesL(i)) & "</a>" & strDelmiL
intTempPage = CInt(aryPagesL(i))
End If
Next
End If
If IsArray(aryPagesM) Then
For i = 0 To UBound(aryPagesM)
If Int(aryPagesM(i)) = Int(currentPage) Then
strHTML = strHTML & "<b>[" & CStr(aryPagesM(i)) & "]</b>"
Else
strHTML = strHTML & "<a href=javascript:fPageClick(" & CStr(aryPagesM(i)) & ")>" & CStr(aryPagesM(i)) & "</a>"
End If
If i <> UBound(aryPagesM) Then
strHTML = strHTML & " "
End If
Next
End If
If IsArray(aryPagesR) Then
Dim strHTMLWork : strHTMLWork = ""
intTempPage = CInt(aryPagesR(UBound(aryPagesR))) + 100
For i = UBound(aryPagesR) To 0 Step -1
If (intTempPage - 1) > CInt(aryPagesR(i)) Then
strHTMLWork = strDelmiR & "<a href=javascript:fPageClick(" & CStr(aryPagesR(i)) & ")>" & CStr(aryPagesR(i)) & "</a>" & strHTMLWork
intTempPage = CInt(aryPagesR(i))
End If
Next
strHTML = strHTML & strHTMLWork
End If
'## 「次へ>>」の表示部分
If Int(currentPage) = Int(currentPage) Then
strHTML = strHTML & " " & GSTR_DIS_FVLH_TTL_FWRD & "</td>"
Else
strHTML = strHTML & " <a href=javascript:fPageClick(" & currentPage+1 & ")>" & GSTR_DIS_FVLH_TTL_FWRD & "</a></td>"
End If
Else
strHTML = strHTML & ""
End If
End Function
Dim lngCurentPage
Dim strHTML
Dim blnRet
If Request.QueryString("crtpage")<>"" Then
lngCurentPage = CLng(Request.QueryString("crtpage"))
Else
lngCurentPage = 1
End If
blnRet = fGetPageHTML(strHTML,1000,lngCurentPage,5,6)
response.write(strHTML)
%>
相关文章推荐
- 分页的解析处理(ASP)
- Asp 解析 XML并分页显示
- asp.net中XmlDocument解析出现出错,处理特殊字符
- ASP.NET MVC实践系列8-对查询后分页处理的解决方案
- ASP.NET中DataGrid分页处理的难题
- 分页插件通用处理,以asp.net mvc为例
- Datatables插件1.10.15版本服务器处理模式ajax获取分页数据实例解析
- ASP.NET 数据分页第三篇 - 结合 Custom Control 处理 GridView 的 UI 呈现
- ASP.NET分页的处理方式
- ASP.Net:异步请求分页示例:Handler.ashx + $.ajax() + Json + 分页处理
- ASP.NET 学习笔记_11 行命令处理 和 分页
- 关于ASP.NET中OnClientClick事件Eval函数解析错误的处理
- Asp 解析 XML并分页显示源码
- ASP.NET中绑定数据控件OnClientClick事件Eval函数解析错误的处理
- Asp 解析 XML并分页显示源码
- C#字符串数组排序 C#排序算法大全 C#字符串比较方法 一个.NET通用JSON解析/构建类的实现(c#) C#处理Json文件 asp.net使用Jquery+iframe传值问题
- IIS突然不解析asp文件的处理步骤
- Asp.net中处理请求中含有&字符的解析报400错误的问题
- Android客户端发送Post/Get请求到Asp.Net服务端一般处理程序Asp.Net进行参数解析
- 解析asp.net的分页控件