数据分页显示按钮,自动获取url链接
作者:冻结回忆 时间:2009-06-22 12:59:00
'/***
' 作 者 :冻结回忆
'修改时间:2007-10-17
'功能说明:数据分页显示按钮,自动获取url链接
'调用方法:mapage(d_count,total,page)
'参数说明:d_count 总记录数 total 总页数 page 当前页
'***/
'/ 获取当前页url
function GetLocationURL()
Dim Url
Dim ServerPort,ServerName,ScriptName,QueryString
ServerName = Request.ServerVariables("SERVER_NAME")
ServerPort = Request.ServerVariables("SERVER_PORT")
ScriptName = Request.ServerVariables("SCRIPT_NAME")
QueryString = Request.ServerVariables("QUERY_STRING")
Url="http://"&ServerName
If ServerPort <> "80" Then Url = Url & ":" & ServerPort
Url=Url&ScriptName
If QueryString <>"" Then Url=Url&"?"& QueryString
GetLocationURL=Url
end function
'/处理?后面的参数
function clearOfpage(myurl)
Dim mynewurl
mynewurl = ""
if Instr(myurl,"?")=0 then
clearOfpage = myurl
Exit function
end if
my_query = split(myurl,"?")
k = my_query(1)
if Instr(k,"&")=0 then
if left(k,4)<>"page" then
clearOfpage = myurl & "&"
else
clearOfpage = my_query(0)
end if
Exit function
end if
j = split(k,"&")
for i=0 to Ubound(j)
if j(i)<>"" and left(j(i),4)<>"page" then
mynewurl = mynewurl & j(i) & "&"
end if
next
clearOfpage = my_query(0) & "?" & mynewurl
end function
'----------------------------------------------------------------------------------
'数据分页:按钮显示 总计 32 条记录 共 1/4 页 首页 上一页 下一页 尾页 跳转到 * 页
'----------------------------------------------------------------------------------
function mapage(d_count,total,page)
Dim myurl,mapclick
myurl = GetLocationURL()
myurl = clearOfpage(myurl)
if Instr(myurl,"?")=0 then
myurl = myurl & "?"
end if
mymap = "总计 "&d_count&" 条记录 共 "&page&"/"&total&" 页 "
if page=1 then
mapclick = " 首页 上一页 "
else
mapclick = " <a href='"&myurl&"page=1'>首页</a> <a href='"&myurl&"page="&page-1&"'>上一页</a> "
end if
if page=total then
mapdbclick = " 下一页 末页 "
else
mapdbclick = " <a href='"&myurl&"page="&page+1&"'>下一页</a> <a href='"&myurl&"page="&total&"'>末页</a> "
end if
jumpclick = vbcrlf&" 跳转到 <select onchange=""window.location.href='"&myurl&"page='+this.value;"">" & vbcrlf
for i=1 to total
if page=i then
jumpclick = jumpclick + "<option value="""&i&""" selected>"&i&"</option>" & vbcrlf
else
jumpclick = jumpclick + "<option value="""&i&""">"&i&"</option>" & vbcrlf
end if
next
jumpclick = jumpclick + " </select> 页" & vbcrlf
mapage = mymap & mapclick & mapdbclick & jumpclick
end function