javascript - Calculating records per page - Stack Overflow

Hi I am new to javascript. The formula that I am using for my application is calculating the wrong last

Hi I am new to javascript. The formula that I am using for my application is calculating the wrong last page number. How it works is when a user enter the page range they want printed it should only print the page range from the start page to the end page. User inputs are first page and last page. Thank you very much

    var rn = parseInt($('reportNumber').value) ;
    var s = parseInt($('startpage').value) ;
    var e = parseInt($('endpage').value) ;
    var l = parseInt($('linesPerPage').value) ;
    var i = (((e-s)+1)*l) ; // calculating the total number of records per page 
    createReport(rn,s,i) 

In another function I am doing this for pagination:

   lastpage = Math.ceil(TotalNumberOfRows/recordsPerPage) ;

Hi I am new to javascript. The formula that I am using for my application is calculating the wrong last page number. How it works is when a user enter the page range they want printed it should only print the page range from the start page to the end page. User inputs are first page and last page. Thank you very much

    var rn = parseInt($('reportNumber').value) ;
    var s = parseInt($('startpage').value) ;
    var e = parseInt($('endpage').value) ;
    var l = parseInt($('linesPerPage').value) ;
    var i = (((e-s)+1)*l) ; // calculating the total number of records per page 
    createReport(rn,s,i) 

In another function I am doing this for pagination:

   lastpage = Math.ceil(TotalNumberOfRows/recordsPerPage) ;
Share Improve this question edited Dec 10, 2013 at 18:48 Peter H asked Dec 10, 2013 at 18:36 Peter HPeter H 311 silver badge3 bronze badges 7
  • 1 What JS library are you using? In jQuery, it should be $('#reportNumber') and so on -- you need # before the ID in selectors. – Barmar Commented Dec 10, 2013 at 18:42
  • Why do you need to calculate records per page? Isn't that what l is? – Barmar Commented Dec 10, 2013 at 18:53
  • I am using JQuery 1.9.1 – Peter H Commented Dec 10, 2013 at 18:54
  • Then you need to add # before all the IDs in the selectors. – Barmar Commented Dec 10, 2013 at 18:56
  • That part of the code works fine – Peter H Commented Dec 10, 2013 at 19:38
 |  Show 2 more ments

1 Answer 1

Reset to default 7

You're dividing by the total number of rows in the page range, you should divide by the number of rows per page.

lastpage = Math.ceil(TotalNumberOfRows/l);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745448969a4628179.html

相关推荐

  • javascript - Calculating records per page - Stack Overflow

    Hi I am new to javascript. The formula that I am using for my application is calculating the wrong last

    10小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信