Posted By

linusx on 04/14/10


Tagged

javascript 1 results 10 - of 304


Versions (?)

Results 1 - 10 of 304 list


 / Published in: JavaScript
 

This will create the text 1 - 10

  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  

You need to login to post a comment.