asp最常用的分页函数

2018-09-06 11:37

阅读:349

  复制代码 代码如下:
rs.opensql,conn,1,1
ifrs.eofandrs.bofthen
response.write<palign=center>还没找到文章</p>
else
totalPut=rs.recordcount
maxperpage=18
ifcurrentpage<1then
currentpage=1
endif
if(currentpage-1)*maxperpage>totalputthen
if(totalputmodmaxperpage)=0then
currentpage=totalput\maxperpage
else
currentpage=totalput\maxperpage+1
endif
endif
ifcurrentpage=1then
showpage1totalput,maxperpage,infotype.asp?id=&request(id)
showcontent()
showpagetotalput,maxperpage,infotype.asp?id=&request(id)
else
if(currentpage-1)*maxperpage<totalputthen
rs.move(currentpage-1)*maxperpage
dimbookmark
bookmark=rs.bookmark
showpage1totalput,maxperpage,infotype.asp?id=&request(id)
showcontent
showpagetotalput,maxperpage,infotype.asp?id=&request(id)
else
currentpage=1
showpage1totalput,maxperpage,infotype.asp?id=&request(id)
showcontent
showpagetotalput,maxperpage,infotype.asp?id=&request(id)
endif
endif
endif
%>
<%
subshowcontent()
%>
<tr>
<tdheight=20class=blueback2><divalign=center>ID</div></td>
<tdclass=blueback2><divalign=center><ahref=javascript:selectall()><fontcolor=#FFFFFF>选择</font></a></div></td>
<tdwidth=355class=blueback2><divalign=center>信息标题</div></td>
<tdwidth=84class=blueback2><divalign=center>更新日期</div></td>
<tdwidth=40class=blueback2><divalign=center>点击</div></td>
<tdwidth=55class=blueback2><divalign=center>添加人</div></td>
<tdwidth=44class=blueback2><divalign=center>编辑</div></td>
<tdwidth=43class=blueback2><divalign=center>删除</div></td>
<tdwidth=62class=blueback2><divalign=center>生成[<ahref=javascript:void(null)onClick=window.open(cshengcheng.asp,,width=0,height=0)><fontcolor=#FFFFFF>归零</font></a>]</div></td>
</tr>
<%

i=1
dowhilenotrs.eof
%>

<tr>
<tdwidth=39height=25bgcolor=#D6DFF7><divalign=center><%=rs(id)%></div></td>
<tdwidth=34bgcolor=#D6DFF7><divalign=center>
<inputtype=checkboxname=dxyidvalue=<%=rs(id)%>>
</div></td>
<tdbgcolor=#D6DFF7><ahref=Article_show.asp?id=<%=rs(id)%>>[<%=rs(type_id)%>]<%thetitle1=rs(title)
strcounts=truelen(thetitle1)
response.writethetitle1
%></a></td>
<%
datetime=rs(datetime)
yname=year(datetime)
mname=month(datetime)
iflen(mname)<2thenmname=0&mname
dname=month(datetime)
iflen(dname)<2thendname=0&dname
foldername=yname&mname
%>
<tdbgcolor=#D6DFF7><divalign=center><ahref=<%=htmlfolder%><%=foldername%>/<%=rs(id)%>.htmtitle=查看生成的静态页面><%=rs(datetime)%></a></div></td>
<tdbgcolor=#D6DFF7><divalign=center><%=rs(hits)%></div></td>
<tdbgcolor=#D6DFF7><divalign=center><%=rs(author)%></div></td>
<tdbgcolor=#D6DFF7><divalign=center><ahref=news_edit.asp?dxy_id=<%=rs(id)%>>修改</a></div></td>
<tdbgcolor=#D6DFF7><divalign=center><ahref=javascript:delxx(<%=rs(id)%>)>删除</a></div></td>
<tdbgcolor=#D6DFF7><divalign=center><ahref=javascript:makehtml(<%=rs(id)%>)>生成(<ahref=javascript:void(null)onClick=window.open(cshengcheng.asp?id=<%=rs(id)%>,,width=0,height=0)><%=rs(shengcheng)%>)</a></div></td>
</tr>
<%
i=i+1
ifi>maxperpagethenexitdo
rs.movenext
loop
%>
<tr>
<tdheight=20class=blueback2><divalign=center>ID</div></td>
<tdclass=blueback2><divalign=center><ahref=javascript:selectall()><fontcolor=#FFFFFF>选择</font></a></div></td>
<tdclass=blueback2><divalign=center>信息标题</div></td>
<tdclass=blueback2><divalign=center>更新日期</div></td>
<tdclass=blueback2><divalign=center>点击</div></td>
<tdclass=blueback2><divalign=center>添加人</div></td>
<tdclass=blueback2><divalign=center>编辑</div></td>
<tdclass=blueback2><divalign=center>删除</div></td>
<tdclass=blueback2><divalign=center>生成</div></td>
</tr>
<%
endsub
%>

<tr>
<tdheight=20colspan=9bgcolor=#D6DFF7><label>
<inputtype=buttonname=dxydovalue=全选onClick=javascript:selectall()>
<inputtype=submitname=dxydovalue=删除onClick={if(confirm(确定要删除选择的信息吗)){document.formselect.submit();returntrue;}returnfalse;}>
<inputtype=submitname=dxydovalue=生成>
<inputtype=submitname=dxydovalue=移动>
</label></td>
</tr>
<%
functionshowpage(totalnumber,maxperpage,filename)
%>
<tr>
<tdheight=20colspan=9bgcolor=#D6DFF7>
<%
dimn
iftotalnumbermodmaxperpage=0then
n=totalnumber\maxperpage
else
n=totalnumber\maxperpage+1
endif
%>
<divalign=center>共有<%=totalnumber%>/<%=maxperpage%>条,

当前页<%=currentpage%>/<%=n%>
<%ifcurrentpage<2then%>
[首页][上一页]
<%else%>
<ahref=<%=filename%>><fontcolor=red>[首页]</font></a><ahref=<%=filename%>&page=<%=currentpage-1%>><fontcolor=red>[上一页]</font></a>
<%endif%><%ifn-currentpage<1then%>
[下一页][尾页]<%else%><ahref=<%=filename%>&page=<%=currentpage+1%>><fontcolor=red>[下一页]</font></a><ahref=<%=filename%>&page=<%=n%>><fontcolor=red>[尾页]</font></a>
<%endif%>
转到:<selectname=ddclass=sle

onChange=location.href=this.options[this.selectedIndex].value>
<%forj=1ton
ifcurrentpage=jthen
%><optionvalue=<%=filename%>&page=<%=j%>selected><%=j%></option>
<%
else
%>
<optionvalue=<%=filename%>&page=<%=j%>><%=j%></option>
<%
endif
next
%>
</select>
</div></td>
</tr>
<%
endfunction
%>
<%
functionshowpage1(totalnumber,maxperpage,filename)
%>
<tr>
<tdheight=20colspan=9bgcolor=#D6DFF7>
<%
dimb
iftotalnumbermodmaxperpage=0then
b=totalnumber\maxperpage
else
b=totalnumber\maxperpage+1
endif
%>
<divalign=center>共有<%=totalnumber%>/<%=maxperpage%>条,

当前页<%=currentpage%>/<%=b%>
<%
dxystart=currentpage-5
ifdxystart<1thendxystart=1
dxyend=currentpage+5
ifdxyend>bthendxyend=b
fordxy=dxystarttodxyend
ifdxy=currentpagethen
response.write[<ahref=&filename&&page=&dxy&>&<fontcolor=red>&dxy&</font>&</a>]&
else
response.write[<ahref=&filename&&page=&dxy&>&dxy&</font>&</a>]&
endif
next
%>
</div></td>
</tr>
<%
endfunction
%>
</form>
</table>
<%
rs.close
setrs=nothing
conn.close
setconn=nothing
%>


评论


亲,登录后才可以留言!