asp最常用的分页函数

时间:2021-05-28

复制代码 代码如下:
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="20"class="blueback2"><divalign="center">ID</div></td>
<tdclass="blueback2"><divalign="center"><ahref="javascript:selectall()"><fontcolor="#FFFFFF">选择</font></a></div></td>
<tdwidth="355"class="blueback2"><divalign="center">信息标题</div></td>
<tdwidth="84"class="blueback2"><divalign="center">更新日期</div></td>
<tdwidth="40"class="blueback2"><divalign="center">点击</div></td>
<tdwidth="55"class="blueback2"><divalign="center">添加人</div></td>
<tdwidth="44"class="blueback2"><divalign="center">编辑</div></td>
<tdwidth="43"class="blueback2"><divalign="center">删除</div></td>
<tdwidth="62"class="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="39"height="25"bgcolor="#D6DFF7"><divalign="center"><%=rs("id")%></div></td>
<tdwidth="34"bgcolor="#D6DFF7"><divalign="center">
<inputtype="checkbox"name="dxyid"value="<%=rs("id")%>">
</div></td>
<tdbgcolor="#D6DFF7"><ahref="Article_show.asp?id=<%=rs("id")%>"target="_blank">[<%=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")%>.htm"title="查看生成的静态页面"target="_blank"><%=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="20"class="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="20"colspan="9"bgcolor="#D6DFF7"><label>
<inputtype="button"name="dxydo"value="全选"onClick="javascript:selectall()">
<inputtype="submit"name="dxydo"value="删除"onClick="{if(confirm('确定要删除选择的信息吗')){document.formselect.submit();returntrue;}returnfalse;}">
<inputtype="submit"name="dxydo"value="生成">
<inputtype="submit"name="dxydo"value="移动">
</label></td>
</tr>
<%
functionshowpage(totalnumber,maxperpage,filename)
%>
<tr>
<tdheight="20"colspan="9"bgcolor="#D6DFF7">
<%
dimn
iftotalnumbermodmaxperpage=0then
n=totalnumber\maxperpage
else
n=totalnumber\maxperpage+1
endif
%>
<divalign="center">共有<%=totalnumber%>/<%=maxperpage%>条,

当前页<%=currentpage%>/<%=n%>&nbsp;
<%ifcurrentpage<2then%>
[首页]&nbsp;[上一页]
<%else%>
<ahref="<%=filename%>"><fontcolor="red">[首页]</font></a>&nbsp;<ahref="<%=filename%>&page=<%=currentpage-1%>"><fontcolor="red">[上一页]</font></a>
<%endif%><%ifn-currentpage<1then%>
[下一页]&nbsp;[尾页]<%else%><ahref="<%=filename%>&page=<%=currentpage+1%>"><fontcolor="red">[下一页]</font></a>&nbsp;<ahref="<%=filename%>&page=<%=n%>"><fontcolor="red">[尾页]</font></a>
<%endif%>
转到:<selectname="dd"class="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="20"colspan="9"bgcolor="#D6DFF7">
<%
dimb
iftotalnumbermodmaxperpage=0then
b=totalnumber\maxperpage
else
b=totalnumber\maxperpage+1
endif
%>
<divalign="center">共有<%=totalnumber%>/<%=maxperpage%>条,

当前页<%=currentpage%>/<%=b%>&nbsp;
<%
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>]"&"&nbsp;"
else
response.write"[<ahref="&filename&"&page="&dxy&">"&dxy&"</font>"&"</a>]"&"&nbsp;"
endif
next
%>
</div></td>
</tr>
<%
endfunction
%>
</form>
</table>
<%
rs.close
setrs=nothing
conn.close
setconn=nothing
%>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章