kellynic写的一个分页模块
作者:dadait 日期:2005-10-31
还可以,给大家参考
程序代码
< %
' 显示上下页(当前页,总页数,前后加起来的页数,除去cp参数的GET串)
function showPage(currentPage,countPage,showPageC,queryStr)
dim i,l,starF,endF,reStr,getStr
const DOT = " <span style=cursor:hand;>..</span> "
l = showPageC 2
if currentPage - l <= 1 then
starF = 1
else
starF = currentPage - l
reStr = reStr & DOT
end if
endF = starF + showPageC
for i = starF to endF
if i > countPage then exit for
if queryStr = "" then
getStr = " cp= " & i
else
getStr = queryStr & " &cp= " & i
end if
if i <> currentPage then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>[ " & i & " ]</a> "
else
reStr = reStr & " <b><font color=#CC9933>[ " & i & " ]</a></b> "
end if
next
if endF < countPage then reStr = reStr & DOT
reStr = reStr & " <span class=green> " & currentPage & " / " & countPage & " " & showTablePageSize & " /页</span> "
' *****************************************************
if queryStr = "" then
getStr = " cp=1 "
else
getStr = queryStr & " &cp=1 "
end if
if currentPage > 1 then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>首页</a> "
else
reStr = reStr & " <font color=#CCCCCC>首页</font> "
end if
' *****************************************************
if queryStr = "" then
getStr = " cp= " & (currentPage - 1 )
else
getStr = queryStr & " &cp= " & (currentPage - 1 )
end if
if currentPage > 1 then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>上页</a> "
else
reStr = reStr & " <font color=#CCCCCC>上页</font> "
end if
' *****************************************************
if queryStr = "" then
getStr = " cp= " & (currentPage + 1 )
else
getStr = queryStr & " &cp= " & (currentPage + 1 )
end if
if currentPage < countPage then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>下页</a> "
else
reStr = reStr & " <font color=#CCCCCC>下页</font> "
end if
' *****************************************************
if queryStr = "" then
getStr = " cp= " & countPage
else
getStr = queryStr & " &cp= " & countPage
end if
if currentPage < countPage then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>末页</a> "
else
reStr = reStr & " <font color=#CCCCCC>末页</font> "
end if
' *****************************************************
showPage = reStr
end function
' 过滤所有的GET串中的cp(当前页数据值),保留其它参数值
function allQueryString()
dim queryTemp,queryT,query
queryTemp = Request.ServerVariables( " QUERY_STRING " )
if queryTemp <> "" then
if instr (queryTemp, " & " ) <> 0 then
queryTemp = split (queryTemp, " & " )
dim queryI
for queryI = LBound (queryTemp) to UBound (queryTemp)
queryT = split (queryTemp(queryI), " = " )
if queryT( 0 ) <> " cp " then
query = query & queryTemp(queryI) & " & "
end if
next
query = left (query, len (query) - 1 )
else
queryTemp = split (queryTemp, " = " )
if queryTemp( 0 ) <> " cp " then
query = queryTemp( 0 ) & " = " & queryTemp( 1 )
end if
end if
end if
allQueryString = query
end function
' 数据显示完毕后只需这两行代码即可,通用性还可以
query = allQueryString()
response.Write(showPage(showTableCurrentPage,showTableCountPage, 9 ,query))
% >
< %
' 显示上下页(当前页,总页数,前后加起来的页数,除去cp参数的GET串)
function showPage(currentPage,countPage,showPageC,queryStr)
dim i,l,starF,endF,reStr,getStr
const DOT = " <span style=cursor:hand;>..</span> "
l = showPageC 2
if currentPage - l <= 1 then
starF = 1
else
starF = currentPage - l
reStr = reStr & DOT
end if
endF = starF + showPageC
for i = starF to endF
if i > countPage then exit for
if queryStr = "" then
getStr = " cp= " & i
else
getStr = queryStr & " &cp= " & i
end if
if i <> currentPage then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>[ " & i & " ]</a> "
else
reStr = reStr & " <b><font color=#CC9933>[ " & i & " ]</a></b> "
end if
next
if endF < countPage then reStr = reStr & DOT
reStr = reStr & " <span class=green> " & currentPage & " / " & countPage & " " & showTablePageSize & " /页</span> "
' *****************************************************
if queryStr = "" then
getStr = " cp=1 "
else
getStr = queryStr & " &cp=1 "
end if
if currentPage > 1 then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>首页</a> "
else
reStr = reStr & " <font color=#CCCCCC>首页</font> "
end if
' *****************************************************
if queryStr = "" then
getStr = " cp= " & (currentPage - 1 )
else
getStr = queryStr & " &cp= " & (currentPage - 1 )
end if
if currentPage > 1 then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>上页</a> "
else
reStr = reStr & " <font color=#CCCCCC>上页</font> "
end if
' *****************************************************
if queryStr = "" then
getStr = " cp= " & (currentPage + 1 )
else
getStr = queryStr & " &cp= " & (currentPage + 1 )
end if
if currentPage < countPage then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>下页</a> "
else
reStr = reStr & " <font color=#CCCCCC>下页</font> "
end if
' *****************************************************
if queryStr = "" then
getStr = " cp= " & countPage
else
getStr = queryStr & " &cp= " & countPage
end if
if currentPage < countPage then
reStr = reStr & " <a href= " / " ? " & getStr & " "" target=_self class=page>末页</a> "
else
reStr = reStr & " <font color=#CCCCCC>末页</font> "
end if
' *****************************************************
showPage = reStr
end function
' 过滤所有的GET串中的cp(当前页数据值),保留其它参数值
function allQueryString()
dim queryTemp,queryT,query
queryTemp = Request.ServerVariables( " QUERY_STRING " )
if queryTemp <> "" then
if instr (queryTemp, " & " ) <> 0 then
queryTemp = split (queryTemp, " & " )
dim queryI
for queryI = LBound (queryTemp) to UBound (queryTemp)
queryT = split (queryTemp(queryI), " = " )
if queryT( 0 ) <> " cp " then
query = query & queryTemp(queryI) & " & "
end if
next
query = left (query, len (query) - 1 )
else
queryTemp = split (queryTemp, " = " )
if queryTemp( 0 ) <> " cp " then
query = queryTemp( 0 ) & " = " & queryTemp( 1 )
end if
end if
end if
allQueryString = query
end function
' 数据显示完毕后只需这两行代码即可,通用性还可以
query = allQueryString()
response.Write(showPage(showTableCurrentPage,showTableCountPage, 9 ,query))
% >