明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

在ASP中,用JScript腳本完成分頁(yè)的另類方法

[摘要]<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%><!--#include file="connect.asp"--><!--#include file="news....

<%@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='集團(tuán)新聞' order by id desc";
DataSet.Open(sql,DataConn,1,1);

//是否有數(shù)據(jù)
if ((DataSet.eof)&&(DataSet.bof))
{
   Response.Write("<BR>" );
   Response.Write("=== 暫無 ===");
   Response.Write("<BR><BR>");
   Response.End();
}

//記錄總數(shù)
NumRecords=DataSet.RecordCount;

//設(shè)定每頁(yè)最大記錄數(shù)
PageSize=3;

//總頁(yè)數(shù)
NumPages=Math.ceil(NumRecords/PageSize);


//當(dāng)前頁(yè)
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;

//內(nèi)容列表
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;
}

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