在ASP中,用JScript脚本实现分页的另类办法。

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!--#include file="connect.asp"-->
<!--#include file="news.asp"-->
<%
var DataSet,sql,DataList;
var i=0;
var j=0;
DataList=new News();
DataSet=Server.CreateObject("Adodb.recordset");
sql="select * from News where ngroup='集团新闻' order by id desc";
DataSet.Open(sql,DataConn,1,1);

//是否有数据
if ((DataSet.eof)&&(DataSet.bof))
{
   Response.Write("<BR>" );
   Response.Write("=== 暂无 ===");
   Response.Write("<BR><BR>");
   Response.End();
}

//记录总数
NumRecords=DataSet.RecordCount;

//设定每页最大记录数
PageSize=3;

//总页数
NumPages=Math.ceil(NumRecords/PageSize);


//当前页
i=Request.QueryString("CurrentPageID").Count;
if (i==0)
{
   CurrentPageID=1;
}
else
{
   CurrentPageID=parseInt(Request.QueryString("CurrentPageID"));
}

//初始化
PreviousPageID=CurrentPageID-1;
NextPageID=CurrentPageID+1;
HomePage=1;
EndPage=NumPages;

//内容列表
DataSet.MoveFirst;
DataSet.Move((CurrentPageID-1)*PageSize,1);
while (!DataSet.eof && j<PageSize)
{
    Response.Write("<a href=show.asp?id="+DataSet("id")+" target=/"_blank/">"+DataSet("subject")+"</a><br>");
 j=j+1;
 DataSet.MoveNext;
}

//设定URL
if (CurrentPageID == HomePage)
{  
   Response.Write("<p class='Normal'><a href=list.asp?CurrentPageID="+HomePage+">首页</a>&nbsp;&nbsp;");
   Response.Write("上一页&nbsp;&nbsp;");
   Response.Write("<a href=list.asp?CurrentPageID="+NextPageID+">下一页</a>&nbsp;&nbsp;");
   Response.Write("<a href=list.asp?CurrentPageID="+EndPage+">尾页</a>&nbsp;&nbsp;</p>");
}
else if (CurrentPageID == EndPage)
    {
        Response.Write("<p class='Normal'><a href=list.asp?CurrentPageID="+HomePage+">首页</a>&nbsp;&nbsp;");
        Response.Write("<a href=list.asp?CurrentPageID="+PreviousPageID+">上一页</a>&nbsp;&nbsp;");
        Response.Write("下一页&nbsp;&nbsp;");
        Response.Write("<a href=list.asp?CurrentPageID="+EndPage+">尾页</a>&nbsp;&nbsp;</p>");
    }
 else
 {
        Response.Write("<p class='Normal'><a href=list.asp?CurrentPageID="+HomePage+">首页</a>&nbsp;&nbsp;");
        Response.Write("<a href=list.asp?CurrentPageID="+PreviousPageID+">上一页</a>&nbsp;&nbsp;");
        Response.Write("<a href=list.asp?CurrentPageID="+NextPageID+">下一页</a>&nbsp;&nbsp;");
        Response.Write("<a href=list.asp?CurrentPageID="+EndPage+">尾页</a>&nbsp;&nbsp;</p>");
 }
%>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值