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);