'=================================================
'函数名:HtmlPagination
'作 用:以分页方式显示文章具体的内容
'参 数:无
'=================================================
Function showhtmlpage(page,Pcount,totalnumber,maxperpage,strFilename,ListName)
Dim strTemp, b, e
Dim pagestart,pageend
Dim i, ii, n, p, s
if totalnumber Mod maxperpage =0 then
Pcount= Int(totalnumber/maxperpage)
else
Pcount= Int(totalnumber/maxperpage) + 1
end if
b = 5 : e = 5 : s = "五"
pagestart = page - 50
pageend = page + 50
If pagestart < 1 Then
pagestart = 2
End If
If pageend > Pcount Then
pageend = Pcount
End If
If (page - 1) Mod b = 0 Then
p = (page-1) \ b
Else
p = ((page-1) - (page-1) Mod b) \ b
End If
If totalnumber Mod maxperpage = 0 Then
n = totalnumber \ maxperpage
Else
n = (totalnumber - totalnumber Mod maxperpage) \ maxperpage + 1
End If
strTemp = "<table border=""0"" cellpadding=""0"" cellspacing=""1"" class=""Tableborder5"">" & vbNewLine
strTemp = strTemp & " <form method=""post"">" & vbNewLine
strTemp = strTemp & " <tr align=""center"">" & vbNewLine
strTemp = strTemp & " <td class=""tabletitle1"" title=""" & ListName & """> " & ListName & " </td>" & vbNewLine
strTemp = strTemp & " <td class=""tabletitle1"" title=""总数""> " & totalnumber & " </td>" & vbNewLine
strTemp = strTemp & " <td class=""tabletitle1"" title=""每页""> " & maxperpage & " </td>" & vbNewLine
strTemp = strTemp & " <td class=""tabletitle1"" title=""页次""> " & page & "/" & Pcount & "页 </td>" & vbNewLine
If page = 1 Then
strTemp = strTemp & " <td class=""tablebody1""> <font face=""webdings"" color=""#000000"">9</font> </td>" & vbNewLine
Else
strTemp = strTemp & " <td class=""tablebody1""> <a href=""" & Replace(strFilename, "[page]", "1", 1, -1, 1) & """ title=""首页""><font face=""webdings"">9</font></a> </td>" & vbNewLine
End If
If p * b > 0 Then
strTemp = strTemp & " <td class=""tablebody1""> <a href=""" & Replace(strFilename, "[page]", p*b, 1, -1, 1) & """ title=""上" & s & "页""><font face=""webdings"">7</font></a> </td>" & vbNewLine
Else
strTemp = strTemp & " <td class=""tablebody1""> <font face=""webdings"" color=""#000000"">7</font> </td>" & vbNewLine
End If
For i = p * b + 1 To p * b + e
If i = page Then
strTemp = strTemp & " <td class=""tablebody2""> <font class=""normalTextSmall""><u><b>" & i & "</b></u></font> </td>" & vbNewLine
Else
strTemp = strTemp & " <td class=""tablebody1""> <a href=""" & Replace(strFilename, "[page]", i, 1, -1, 1) & """ title=""第" & i & "页"">" & i & "</a> </td>" & vbNewLine
End if
If i = n Then Exit For
Next
If i < n Then
strTemp = strTemp & " <td class=""tablebody1""> <a href=""" & Replace(strFilename, "[page]", i, 1, -1, 1) & """ title=""下" & s & "页""><font face=""webdings"">8</font></a> <td>" & vbNewLine
Else
strTemp = strTemp & " <td class=""tablebody1""> <font face=""webdings"" color=""#000000"">8</font> <td>" & vbNewLine
End If
If page = n Then
strTemp = strTemp & " <td class=""tablebody1""> <Font face=""webdings"" color=""#000000"">:</font> </td>" & vbNewLine
Else
strTemp = strTemp & " <td class=""tablebody1""> <a href=""" & Replace(strFilename, "[page]", n, 1, -1, 1) & """ title=""尾页""><font face=""webdings"">:</font></a> </td>" & vbNewLine
End If
strTemp = strTemp & " <td class=""tabletitle1"" title=""转到""> GO </td>" & vbNewLine
strTemp = strTemp & "<td class=""tablebody1""><select class=""PageInput"" name=""page"" size=""1"" onchange=""javascript:window.location=this.options[this.selectedIndex].value;"">" & vbNewLine
strTemp = strTemp & " <option value=""" & Replace(strFilename, "[page]", "1", 1, -1, 1) & """>第1页</option>"
If pagestart > 1 Then
For ii = pagestart To pageend'Pcount
If ii = page Then
strTemp = strTemp & "<option value=""" & Replace(strFilename, "[page]", ii, 1, -1, 1) & """ selected>第" & ii & "页</option>"
Else
strTemp = strTemp & "<option value=""" & Replace(strFilename, "[page]", ii, 1, -1, 1) & """>第" & ii & "页</option>"
End If
Next
End If
strTemp = strTemp & "</select></td>" & vbNewLine
strTemp = strTemp & " </tr>" & vbNewLine
strTemp = strTemp & " </form>" & vbNewLine
strTemp = strTemp & "</table>" & vbNewLine
showhtmlpage = strTemp
End Function
CSS样式:
/*-------------------分页效果开始--------------------*/
.mainNextPage {float: left;margin: auto;width: 100%;padding: 2px 0;}
.mainNextPage table {width: auto;border: 1px #1C6EAC solid; background-color: #D6E0EF;float: right;}
.mainNextPage table td { background-color: #FFFFFF; line-height: normal; }
.mainNextPage table td.tabletitle1{ clear: both;background-color: #1C6EAC; color: #FFFFFF; }
.mainNextPage table td input.PageInput {border: solid 1px #d6e0ef; background-color: #fafafa; height: 16px; font-family: arial; font-size:11.5px;}
.mainNextPage table td input.button {border: solid 1px #d6e0ef; background-color: #fafafa; height: 20px; font-family: arial; font-size:11.5px;}
.mainNextPage table td .normalTextSmall { font-size: 11px; color: #FF0000; font-family: Verdana, Arial, Helvetica, sans-serif; }
.mainNextPage a {font-size: 12px;color: #333;text-decoration: none;}
.mainNextPage a:hover {font-size: 12px;color:#ff3300;text-decoration: underline;}
/*-------------------分页效果结束--------------------*/
调用方法:
if totalput>0 then
PageList=showhtmlpage(currentpage,pcount,totalput,maxperpage,strFilename,"栏目名字")
response.write PageList
end if