In ASP, an alternative way to implement pagination with JScript script

Source: Internet
Author: User
Tags include prev

<% @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);

Is there any data
if ((dataset.eof) && (DATASET.BOF)
{
Response.Write ("<BR>");
Response.Write ("= = = = = No = = = no)";
Response.Write ("<BR><BR>");
Response.End ();
}

Total Records
Numrecords=dataset.recordcount;

Set maximum number of records per page
pagesize=3;

Total pages
Numpages=math.ceil (numrecords/pagesize);


Current page
I=request.querystring ("Currentpageid"). Count;
if (i==0)
{
currentpageid=1;
}
Else
{
Currentpageid=parseint (Request.QueryString ("Currentpageid"));
}

Class
Previouspageid=currentpageid-1;
nextpageid=currentpageid+1;
homepage=1;
Endpage=numpages;

Content List
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;
}

Set URL
if (Currentpageid = = homepage)
{
Response.Write ("<p class= ' Normal ' ><a href=list.asp?) Currentpageid= "+homepage+" > Home </a> ");
Response.Write ("previous page");
Response.Write ("<a href=list.asp?") Currentpageid= "+nextpageid+" > Next </a> ");
Response.Write ("<a href=list.asp?") Currentpageid= "+endpage+" > Last </a> </p> ");
}
else if (Currentpageid = = endpage)
{
Response.Write ("<p class= ' Normal ' ><a href=list.asp?) Currentpageid= "+homepage+" > Home </a> ");
Response.Write ("<a href=list.asp?") Currentpageid= "+previouspageid+" > Prev </a> ");
Response.Write ("next page");
Response.Write ("<a href=list.asp?") Currentpageid= "+endpage+" > Last </a> </p> ");
}
Else
{
Response.Write ("<p class= ' Normal ' ><a href=list.asp?) Currentpageid= "+homepage+" > Home </a> ");
Response.Write ("<a href=list.asp?") Currentpageid= "+previouspageid+" > Prev </a> ");
Response.Write ("<a href=list.asp?") Currentpageid= "+nextpageid+" > Next </a> ");
Response.Write ("<a href=list.asp?") Currentpageid= "+endpage+" > Last </a> </p> ");
}
%>

Turn from: Dynamic Network production guide www.knowsky.com

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.