Home > Web Front-end > JS Tutorial > Code to achieve paging effect through getList function under js_javascript skills

Code to achieve paging effect through getList function under js_javascript skills

WBOY
Release: 2016-05-16 18:19:21
Original
1312 people have browsed it

Use js to implement page pagination:

Copy code The code is as follows:

< table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color:#D2EBF3;" height="32">

Previous page

Home page
Last page
//Press the pull-down to display the number of pages




getPage() is a js function, as follows:

Copy code The code is as follows:

//Parameter description: lblPostsCount: The total number of records, by getActivityCount obtained; iPageIndex: global variable, current page number
function getPage(page)
{
if(page==0)//Return to homepage
{
iPageIndex=1;
document.form1.PageCtl1_select.options[iPageIndex-1].selected="true"; //The drop-down box displays the page, the array starts 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 on the previous page or stay on the first page
iPageIndex=1;
else if(iPageIndex>Math.round (lblPostsCount/6))//If it is Click the next page on the last page to stay 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() //Get 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 ; Display 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 function on which page:




Copy the code The code is as follows: function SD_Web_PageCtlGoOtherPage(pageNo)
{
getActivityList(pageNo);
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template