I am stuck on this jquery

Both is fine.
I was unaware of your page structure, so I chose to prepend to the body, as that had to be there.

Not to sure how the pagination functionality works.
This way, at least it is called after that AJAX response has returned.
Maybe this is not necessary.
Why don’t you play around with it and see what works.

No problem. You’re welcome.

Hi pullo, is it possible that every page we will show 5 rows in the table,example if i will click next it will display the 5 sets or 5 row in my table.?

Thank you in advance.

Hi jemz,

Assuming that your pagination logic is still in a function:

function sortPagination(){
  $('.myTable tr').hide().filter(':lt(6)').show();
  $('.pagination').jqPagination({
    max_page : Math.ceil($('.myTable tr').length /5),
    paged : function(page) {
      $('.myTable tr:not(:first)').hide();
      var index = ((page-1)*5)+1;
      for (var i=0; i<5; i++){
        $($('.myTable tr')[index]).show();
        index ++;
      }
    }
  });
}

Hi pullo, Okay as i undersstand on this

First you divide the length it by 5 and then the result with that you get the ceil ?

max_page : Math.ceil($(‘.myTable tr’).length /5),

and also this you multiply by 5 and you plus 1,why is it plus 1 ?

var index = ((page-1)*5)+1;

Thank you for the quick reply :slight_smile:

Hey jemz,

max_page is a variable, indicating how many pages (or sets) there will be to paginate through.
As you want to display 5 records (table rows) on each page we have to get the total amount of rows and divide it by five.
In the case that the result is not a whole number, we round it up to the next integer using Math.ceil.

e.g. 15 rows
15/5 = 3

e.g. 16 rows
16/5 = 3.2.
Math.ceil(3.2) = 4

The plus one accounts for the table header (which is also a table row).

HTH

Hi pullo, Thank you again for this…it’s working paginating 5 rows. :slight_smile:

Yay :nanaman:

Hi pullo, I get back to you because i have problem on loading my page with pagination,…when i tried to put my page on the host,my page is very slow in displaying the pagination.Does this affect in the code that we use?

Not really.
Can you post a link to your code on your hosts servers.