Server-side JScript Recordset Paging function/object by Shawl.qiu

Source: Internet
Author: User
Tags cdata functions numeric net numeric value query return xmlns
js|jscript| Objects | pagination | functions | Recordset

Server-side JScript Recordset Paging function/object by Shawl.qiu

Description
Pagination in fact very simple, I have written several paging function ...

Feel JScript write code more convenient than VBScript, basic love with class C syntax to write code, basic grammar quick to see do not understand ....

Alas, there's nothing to say, this time with JScript two paging programs, one for JScript and one for JScript functions, I prefer JScript objects, and do not need to be used as new obj like function objects.

Note: Objects need to be defined before they are used, and function objects can be defined after use.

Advertising time:
My HTML editor has been written, named Sqeditor, to support Opera, IE, Firefox.
Temporarily not open.

Report:
VBS Recordset Paging: ASP VBScript paging function by STABX, third edition
Url:http://blog.csdn.net/btbtd/archive/2006/05/31/765595.aspx

VBS article pagination:
ASP Common article paging function (non-recordset paging), returns multiple results, dictionary implementation by Shawl.qiu
Url:http://blog.csdn.net/btbtd/archive/2006/09/04/1175126.aspx

Directory:
1. JScript Recordset Paging objects
2. JScript Recordset Paging Function object

Shawl.qiu
2006-11-26
Http://blog.csdn.net/btbtd

1. JScript Recordset Paging objects

LineNum


<% @LANGUAGE = "JAVASCRIPT" codepage= "65001"%>


<%


//-----------------------------Begin object Opgnt-----------------------------//


var opgnt={


//------------------------------------begin list


list:function (obj, Articleinpage, Pagelink, currentpage, identifier) {


        /*------------------------------------------------*\


* Server-side JScript Recordset Paging object by Shawl.qiu


* ----------------------


* Parameter Description:


* obj: Object, Recordset object;


* Articleinpage: value, paging size per page;


* Pagelink: value, display the number of page links;


* CurrentPage: Numeric value, the page position of the current request query.


* Identifier: String that accesses the paging request identifier.


        \*------------------------------------------------*/


if (!obj) return false;


if (obj. eof| | Obj. BOF) return false;


if (!articleinpage) var articleinpage=10;


if (!currentpage) var currentpage=1;


            


var all=rs. RecordCount;


var Pgall=math.ceil (Rs. Recordcount/articleinpage);


            


if (Articleinpage>all) return false;


            


var first= ' home ', last= ' last ', next= ' next ', previous= ' on one ';


var next10= ' next ten ', previous10= ' on 10 ';


            


var url= '? ' +request.servervariables ("query_string") + ' & ' +identifier+ ' = ';


var re=new RegExp (identifier+ ' \=.* ', ' I ')


url=url.replace (re,identifier+ ' = '). Replace ('?& ', '? '). Replace (' && ', ' & ');


            


if (!articleinpage) var articleinpage=10; Obj. Pagesize=articleinpage; Set per page size


if (currentpage<1) currentpage=1; Current Page


if (currentpage>pgall) Currentpage=pgall;


Rs. Absolutepage=currentpage;


            


currentpage>1? Response.Write (' <a href= "' +url+ ' 1" > ' +first+ ' </a> ')


: Response.Write (' <span class= ' nonlink ' > ' +first+ ' </span> ');


            


if (pgall>pagelink)


Currentpage>10? Response.Write (' <a href= "' +url+ (currentpage-0-10-(currentpage%10) +1) + ' > ' +


previous10+ ' </a> '): Response.Write (' <span class= ' nonlink ' > ' +previous10+ ' </span> ');


            


currentpage>1? Response.Write (' <a href= "' +url+ (currentPage-1) + '" > ' +previous+ ' </a> ')


: Response.Write (' <span class= ' nonlink ' > ' +previous+ ' </span> ');


            


For (Var i=0, temp=currentpage-(currentpage%pagelink) +1, temp_= '; i<pagelink; temp++, i++) {


if (temp>pgall) break;


temp==currentpage? Response.Write (' <span class= ' curlink ' > ' +temp+ ' </span> ')


: Response.Write (' <a href= "' +url+temp+ '" > ' +temp+ ' </a> ');


            }


            


Currentpage<pgall? Response.Write (' <a href= "' +url+ (currentpage-0+1) + '" > ' +next+ ' </a> ')


: Response.Write (' <span class= ' nonlink ' > ' +next+ ' </span> ');


            


if (pgall>pagelink)


currentpage<pgall-9? Response.Write (' <a href= "' +url+ (currentpage-0+10-(currentpage%10) +1) + ' > ' +


next10+ ' </a> '): Response.Write (' <span class= ' nonlink ' > ' +next10+ ' </span> ');


            


Currentpage!=pgall? Response.Write (' <a href= "' +url+pgall+ '" > ' +last+ ' </a> ')


: Response.Write (' <span class= ' nonlink ' > ' +last+ ' </span> ');


        },


//------------------------------------End list


//BEGIN info


info:function (obj, Articleinpage, pagelink) {


/* parameter settings ibid; */


if (!obj) return false;


if (obj. eof| | Obj. BOF) return false;


Response.Write (articleinpage+ ' articles/pages ');


Response.Write (obj. Absolutepage+ '/' +obj. pagecount+ ' page ');


Response.Write (' Total ' +obj. recordcount+ ' article ');


        }


//------------------------------------End list


}//Shawl.qiu code


//-----------------------------End Object Opgnt-------------------------------//


%>


<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


<html xmlns= "http://www.w3.org/1999/xhtml" >


<!--DW6-->


<head>


<meta http-equiv= "Content-type" content= "text/html"; Charset=utf-8 "/>


<title>shawl.qiu template</title>


<style type= "Text/css" >


/* <! [cdata[* *


. Curlink{color: #ffccff;}


. Nonlink{color: #CCCCCC;}


/*]]> * *


</style>


</head>


<body>


<%


var conn= "provider=microsoft.jet.oledb.4.0;persist Security info=false;data source=" +


Server.MapPath ("/sqeditor/data/shawlqiu.mdb");


    


var page=request.querystring (' page ') >0? Request.QueryString (' page '): 1;


var pageshow=20;


    


var rs=new activexobject (' Adodb.recordset ');


Rs. Open ("SELECT * from Shawlqiu_ ORDER BY ArticleID DESC", conn, 1);


    


opgnt.list (RS, pageshow, ten, page, ' page ');


Response.Write (' <br/> ');


Opgnt.info (RS, pageshow, 10);


Response.Write (' <p/> ');


        


for (var i=0 i<pageshow; i++) {


if (Rs. eof| | Rs. BOF) break;


Response.Write (RS (' title ') + ' +rs (' ArticleID '));


Response.Write (' <br/> ');


Rs. MoveNext


        }


Delete rs;


%>


</body>


</html>

2. JScript Recordset Paging Function object

LineNum


<% @LANGUAGE = "JAVASCRIPT" codepage= "65001"%>


<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">


<html xmlns= "http://www.w3.org/1999/xhtml" >


<!--DW6-->


<head>


<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>


<title>shawl.qiu template</title>


<style type= "Text/css" >


/* <! [cdata[* *


. Curlink{color: #ffccff;}


. Nonlink{color: #CCCCCC;}


/*]]> * *


</style>


</head>


<body>


<%


var conn= "provider=microsoft.jet.oledb.4.0;persist Security info=false;data source=" +


Server.MapPath ("/sqeditor/data/shawlqiu.mdb");


    


var page=request.querystring (' page ') >0? Request.QueryString (' page '): 1;


    


var rs=new activexobject (' Adodb.recordset ');


Rs. Open ("SELECT * from Shawlqiu ORDER BY ArticleID DESC", conn, 1);


    


var pgnt=new fpagination ()


Pgnt.list (RS, N, page, ' page ');


Response.Write (' <br/> ')


Pgnt.info (RS, 20, 10);


Pgnt=null


            


Rs=null;


    


//-----------------------------Begin object Fpagination-----------------------------//


function Fpagination () {


//------------------------------------begin list


this.list=function (obj, Articleinpage, Pagelink, currentpage, identifier) {


        /*------------------------------------------------*\


* Service-side JScript Recordset Paging function object by Shawl.qiu


         * ----------------------


* Parameter Description:


* obj: Object, Recordset object;


* Articleinpage: value, paging size per page;


* Pagelink: value, display the number of page links;


* CurrentPage: Numeric value, the page position of the current request query.


* Identifier: String that accesses the paging request identifier.


        \*------------------------------------------------*/


if (!obj) return false;


if (obj. eof| | Obj. BOF) return false;


if (!articleinpage) var articleinpage=10;


if (!currentpage) var currentpage=1;


            


var all=rs. RecordCount;


var Pgall=math.ceil (Rs. Recordcount/articleinpage);


            


if (Articleinpage>all) return false;


            


var first= ' home ', last= ' last ', next= ' next ', previous= ' on one ';


var next10= ' next ten ', previous10= ' on 10 ';


            


var url= '? ' +request.servervariables ("query_string") + ' & ' +identifier+ ' = ';


var re=new RegExp (identifier+ ' \=.* ', ' I ')


url=url.replace (re,identifier+ ' = '). Replace ('?& ', '? '). Replace (' && ', ' & ');


            


if (!articleinpage) var articleinpage=10; Obj. Pagesize=articleinpage; Set per page size


if (currentpage<1) currentpage=1; Current Page


if (currentpage>pgall) Currentpage=pgall;


Rs. Absolutepage=currentpage;





currentpage>1? Response.Write (' <a href= "' +url+ ' 1" > ' +first+ ' </a> ')


: Response.Write (' <span class= ' nonlink ' > ' +first+ ' </span> ');


            


if (pgall>pagelink)


currentpage>10? Response.Write (' <a href= "' +url+ (currentpage-0-10-(currentpage%10) +1) + ' > ' +


previous10+ ' </a> '): Response.Write (' <span class= ' nonlink ' > ' +previous10+ ' </span> ');





currentpage>1? Response.Write (' <a href= "' +url+ (currentPage-1) + '" > ' +previous+ ' </a> ')


: Response.Write (' <span class= ' nonlink ' > ' +previous+ ' </span> ');


            


for (Var i=0, temp=currentpage-(currentpage%pagelink) +1, temp_= '; i<pagelink; temp++, i++) {


if (temp>pgall) break;


Temp==currentpage? Response.Write (' <span class= ' curlink ' > ' +temp+ ' </span> ')


: Response.Write (' <a href= "' +url+temp+ '" > ' +temp+ ' </a> ');


            }


            


Currentpage<pgall? Response.Write (' <a href= "' +url+ (currentpage-0+1) + '" > ' +next+ ' </a> ')


: Response.Write (' <span class= ' nonlink ' > ' +next+ ' </span> ');


            


if (Pgall>pagelink)


currentpage<pgall-9? Response.Write (' <a href= "' +url+ (currentpage-0+10-(currentpage%10) +1) + ' > ' +


next10+ ' </a> '): Response.Write (' <span class= ' nonlink ' > ' +next10+ ' </span> ');


            


Currentpage!=pgall? Response.Write (' <a href= "' +url+pgall+ '" > ' +last+ ' </a> ')


: Response.Write (' <span class= ' nonlink ' > ' +last+ ' </span> ');


        }


------------------------------------End List


//BEGIN info


this.info=function (obj, Articleinpage, pagelink) {


/* parameter settings ibid; */


if (!obj) return false;


if (obj. eof| | Obj. BOF) return false;


Response.Write (articleinpage+ ' articles/pages ');


Response.Write (obj. Absolutepage+ '/' +obj. pagecount+ ' page ');


Response.Write (' Total ' +obj. recordcount+ ' article ');


}


//------------------------------------End list


}//Shawl.qiu code


//-----------------------------End Object Fpagination-------------------------------//


%>


</body>


</html>








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.