Code _ javascript tips for implementing paging effect using the getList function in js

Source: Internet
Author: User
Code that uses the getList function to implement paging effect in js. For details about how to use js paging, see. Use js to implement page paging:

The Code is as follows:





Previous Page
Next Page
Homepage
Last page



GetPage () is a js function, as follows:

The Code is as follows:


// Parameter description: lblPostsCount: Total number of records, obtained by getActivityCount; iPageIndex: global variable, current page number
Function getPage (page)
{
If (page = 0) // return to the home page
{
IPageIndex = 1;
Document. form1.PageCtl1 _ select. options [iPageIndex-1]. selected = "true"; // the page number displayed in the drop-down box, starting from 0
GetActivityList (1 );
}
Else if (page = 11) // return to the last page
{

IPageIndex = Math. round (lblPostsCount/6 );
Document. form1.PageCtl1 _ select. options [iPageIndex-1]. selected = "true ";
GetActivityList (iPageIndex );
}
Else // Previous Page, next page
{
IPageIndex = iPageIndex + page;
If (iPageIndex <= 0) // if it is the first page, click the previous page, or keep it on the first page
IPageIndex = 1;
Else if (iPageIndex> Math. round (lblPostsCount/6) // if the last page is still clicked on the next page, keep it on the last page
IPageIndex = Math. round (lblPostsCount/6 );
Else
{
Document. form1.PageCtl1 _ select. options [iPageIndex-1]. selected = "true ";
GetActivityList (iPageIndex); // call List
}
}
}

Function getActivityCount () // gets the number of records
{
Var variable = ['strwhere'];
Var value = new Array (1 );
Value [0] = "iStatus = 2 and iPublic = 5 ";
NewRequest ("getActivityCount", variable, value, getAllActivityCountShow );
BeginRequest ();
}
Function getAllActivityCountShow ()
{
Var xmlhttp = xmlHttpRequest;
Var str = xmlhttp. responseText;
Var value = GetValue (str, "getActivityCountResult ");
LblPostsCount = value; // total number of records
Document. form1.PageCtl1 _ select. length = 0; // The initial drop-down box. The page number is displayed in the value and text of the drop-down box;
For (I = 1; I <= Math. round (lblPostsCount/6); I ++)
{
Var option = document. createElement ("option ");
Option. value = I;
Option. text = I;
Document. form1.PageCtl1 _ select. options. add (option );
}
}



Click the drop-down box to display the page functions:

The Code is as follows:


Function SD_Web_PageCtlGoOtherPage (pageNo)
{
GetActivityList (pageNo );
}

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.