Link to home
Start Free TrialLog in
Avatar of sharepoint0520
sharepoint0520

asked on

Calculate the Total pages from Total items and RawLimit in Javascript?

Hi,
 I am working on custom pagination where i need to calculate the total pages to help with Total count and Rawlimit variable. I am using some manually code. Can you please help me to update my code to calculate Total number of pages?

      var totalItems = 1200;
      var RawLimit = 30;
     
    var totalPages = (totalItems /RawLimit) +1;  // Mod function  

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Hagay Mandel
Hagay Mandel
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hagay is right you need always the integer version so the use of ceiling is your best choice since it will rounds a number UPWARDS to the nearest integer, for example :

101/10 ==> //Return "10.1"
Math.ceil(101/10); ==> //Here the ceiling will round it to "11"

Open in new window

Avatar of sharepoint0520
sharepoint0520

ASKER

Thank you Hagay and Zakaria.