//Maximum data amount var total="100"; //Display amount per page var pagesize =10; //How many pages are there in total var pagenum=Math.ceil(total/pagesize); //Generate navigation function initpage(nowpage){ v"/> //Maximum data amount var total="100"; //Display amount per page var pagesize =10; //How many pages are there in total var pagenum=Math.ceil(total/pagesize); //Generate navigation function initpage(nowpage){ v">
Home >Backend Development >PHP Tutorial >listview paging JS implements pseudo paging in php
The JS code is as follows:
Copy the code The code is as follows:
//Maximum data amount
var total="100";
//Display amount per page
var pagesize=10;
//How many pages are there in total
var pagenum=Math.ceil(total/pagesize);
//Generate navigation
function initpage(nowpage){
var pagenav='Previous page';
for(i=1;i<=pagenum;i++){
pagenav += (i==nowpage)?' ' + i + '':'' + i + ' ';
}
pagenav += 'Next page';
document .getElementById('pages').innerHTML=pagenav;
}
//Turn pages
function goToPage(page){
var start=(page-1)*pagesize;
var max=page*pagesize;
for(vs =0;vs
obj.style.display="none";
}
if(max>total)max=total;
for(v=start;v
obj.style.display="block";
}
initpage(page);
}
//Previous page
function up(nowpage){
if(nowpage==1)return false;
if(nowpage>1)goToPage((nowpage-1));
}
//Next page
function down (nowpage){
if(nowpage==pagenum)return false;
if(nowpage
The above introduces listview paging. JS implements pseudo paging in PHP, including listview paging. I hope it will be helpful to friends who are interested in PHP tutorials.