Results 1 - 10 of 304 list


/ Published in: JavaScript
Save to your folder(s)

This will create the text 1 - 10


Copy this code and paste it in your HTML
  1. currentPage = 2;
  2. totalItems = 304;
  3. perPage = 10;
  4.  
  5. if(curentPage == 1){
  6. if(totalItems > perPage){
  7. of = '1 - ' + perPage;
  8. }else{
  9. of = '1 - ' + totalItems;
  10. }
  11. }else{
  12. nextMax = (parseInt(currentPage) * parseInt(perPage));
  13. x = (parseInt(nextMax) - parseInt(perPage)) + 1;
  14. if(nextMax >= totalItems){ nextMax = totalItems; }
  15. of = x + " - " + nextMax;
  16. }
  17.  
  18. document.write "Results " + of + " of " + totalITems;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.