Use JScript to implement Paging

Source: Internet
Author: User

<% @ 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 = 'group News 'order by id desc ";
DataSet. Open (SQL, DataConn, 1, 1 );

// Whether data exists
If (DataSet. eof) & (DataSet. bof ))
{
Response. Write ("
");
Response. Write ("===no === ");
Response. Write ("
");
Response. End ();
}

// Total number of records
NumRecords = DataSet. RecordCount;

// Set the maximum number of records per page
PageSize = 3;

// Total number of pages
NumPages = Math. ceil (NumRecords/PageSize );


// Current page
I = Request. QueryString ("CurrentPageID"). Count;
If (I = 0)
{
CurrentPageID = 1;
}
Else
{
CurrentPageID = parseInt (Request. QueryString ("CurrentPageID "));
}

// Initialization
PreviousPageID = CurrentPageID-1;
NextPageID = CurrentPageID + 1;
HomePage = 1;
EndPage = NumPages;

// Content list
DataSet. MoveFirst;
DataSet. Move (CurrentPageID-1) * PageSize, 1 );
While (! DataSet. eof & j {
Response. Write ("" + DataSet ("subject") +"
");
J = j + 1;
DataSet. MoveNext;

}

 

 

// Set the URL
If (CurrentPageID = HomePage)
{
Response. Write ("

Homepage ");
Response. Write ("Previous Page ");
Response. Write ("next page ");
Response. Write ("Last Page

");
}
Else if (CurrentPageID = EndPage)
{
Response. Write ("
Homepage ");
Response. Write ("Previous Page ");
Response. Write ("next page ");
Response. Write ("Last Page

");
}
Else
{
Response. Write ("
Homepage ");
Response. Write ("Previous Page ");
Response. Write ("next page ");
Response. Write ("Last Page

");
}
%>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.