admin管理员组文章数量:1430689
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
1 Answer
Reset to default 7You'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);
本文标签: javascriptCalculating records per pageStack Overflow
版权声明:本文标题:javascript - Calculating records per page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745448968a2658795.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论