Home > Backend Development > PHP Tutorial > listview paging JS implements pseudo paging in php

listview paging JS implements pseudo paging in php

WBOY
Release: 2016-07-29 08:38:03
Original
929 people have browsed it

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 var ōbj=document.getElementById('item_' + vs);
obj.style.display="none";
}
if(max>total)max=total;
for(v=start;v var ōbj=document.getElementById('item_' + 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}



If the data is
  • .........

  • .........

  • ... ........
  • ........

  • Then you can display a navigation similar to this:
    Previous page 1 2 3 4 Next page
    Then click on the page number or the previous and next pages to switch the display.

    I am short of time, so that’s all. Please analyze the code yourself. If you don’t understand, please leave a message

    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.

    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