Home > Backend Development > PHP Tutorial > JS implements pseudo paging in php_PHP tutorial

JS implements pseudo paging in php_PHP tutorial

WBOY
Release: 2016-07-21 15:52:07
Original
754 people have browsed it

The JS code is as follows:

Copy code The code is as follows:


/ /Maximum amount of data
var total="100";
//Amount of display 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='Up One page';
for(i=1;i<=pagenum;i++){
pagenav += (i==nowpage)?' ' + i + '':'' + i + ' ' ;
}
pagenav += 'Next page';
document.getElementById(' pages').innerHTML=pagenav;
}

//Turn page
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}
< ;/scrīpt>




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.



    Time is tight, That’s all. Please analyze the code yourself. If you don’t understand, please leave a message

    www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318995.htmlTechArticleJS code is as follows: Copy the code as follows: scrīptlanguage="javascrīpt" //Maximum data amount vartotal="100" ; //The display amount of each page varpagesize=10; //How many pages are there in total varpagenum=Math....
    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