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 );
}