recordsInView(rowsPerPage, currentPage, recordCount)
Last updated January 20, 2009
Version: 0 | Requires: CF5 | Library: StrLib
Description:
Creates easy pagination output ie: (now showing) 101 to 105 of 105 (records) sort of thing.
Return Values:
Returns a string.
Example:
<cfoutput>recordsInView(20,6,105) produces:<br /> #recordsInView(20,6,105)#</cfoutput>
Parameters:
Name | Description | Required |
---|---|---|
rowsPerPage | Number of rows per page. | Yes |
currentPage | Current page. | Yes |
recordCount | Total number of rows. | Yes |
Full UDF Source:
/**
* Creates an easy reccord pagination indicator.
*
* @param rowsPerPage Number of rows per page. (Required)
* @param currentPage Current page. (Required)
* @param recordCount Total number of rows. (Required)
* @return Returns a string.
* @author Tony Felice (sites@breckcomm.com)
* @version 0, January 20, 2009
*/
function recordsInView(rowsPerPage,currentPage,recordCount){
var first = "";
var last = "";
var output = "";
if(currentPage eq 1){
first = 1;
}else{
first = rowsPerPage*(currentPage - 1)+1;
}
if(rowsPerPage - ((currentPage*rowsPerPage) - recordCount) gt rowsPerPage){
last = currentPage*rowsPerPage;
}else{
last = recordCount;
}
if(first lt last){
output = first & " to " & last & " of " & recordCount;
}else if (first eq recordCount){
output = first & " of " & recordCount;
}else if (first gt recordCount){
output = recordCount & " of " & recordCount;
}
return output;
}
Search CFLib.org
Latest Additions
Raymond Camden added
QueryDeleteRows
November 04, 2017
Leigh added
nullPad
May 11, 2016
Raymond Camden added
stripHTML
May 10, 2016
Kevin Cotton added
date2ExcelDate
May 05, 2016
Raymond Camden added
CapFirst
April 25, 2016