Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Next and previous

Posted on 2000-03-17
4
Medium Priority
?
266 Views
Last Modified: 2013-12-24
Hi there...

I have a cfm page which searches a database and then uses the query to display results using cfooutput into a number of text fields on the page.

What is the easiest way to provide a NEXT button which would display the next found record in the fields.

thanks for the help.
0
Comment
Question by:RICHARDH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 37

Expert Comment

by:meverest
ID: 2630081
It gioes something like this.  i do this from memory, so i apologise in advance if i do not have the tags right - ie, i can't remember if it is maxrows or rowcount or maxrecords or whatever, but the basic structure should be enough to give you the idea....

<cfset maxrows=10>

<cfif isdefined('form.startrow')>
  <cfset startrow=form.startrow>
<cfelse>
  <cfset startrow=1>
</cfif>

<cfquery name=list ... ... ...>
  [sql stuff]
</cfquery>

<cfif isdefined('form.next')>
  <cfset startrow = min(startrow+10, list.recordcount-10)>
</cfif>

<cfif isdefined('form.prev')>
  <cfset startrow=max(startrow-10, 1)>
</cfif>
<form action="thisform.cfm" method=post>

<cfoutput>Displaying records #startrow# - #startrow+10# of #list.recordcount#<p></cfoutput>

[table heading]
<cfoutput query=list startrow=#startrow# maxrows=#maxrows#>
  [table stuff]
</cfquery>
<cfif startrow gt 1><input type=submit name=prev value="PREV #maxrows#"></cfif>
<cfif startrow lt list.recordcount><input type=submit name=next value="NEXT #maxrows#"></cfif>
</form>



0
 

Expert Comment

by:mimilafleur
ID: 2630158
hi Richard
you may find the answer at this address (hopefully)

http://www.cftutorials.com/index.cfm?mode=DisplayTutorial&TuUUID=CA3C99A0-EC34-11D3-85030050DABEAE1B

good luck

mimi
0
 
LVL 1

Expert Comment

by:rod_nolan
ID: 2631545
Hi Richard,

I've also answered this one a few times in this group.  You can find the most recent one at http://www.experts-exchange.com/jsp/qShow.jsp?ta=coldfusion&qid=10310035 

Generally, it's probably best to search through the previously answered questions list before you post a question. You might get your answer a bit quicker and it'll cost you less points. :)

Good Luck,
Rod
0
 

Accepted Solution

by:
lcj earned 100 total points
ID: 2707166
Try the following code

You should replace "cfparam name" to your field variables.

<!-- Initialise constants -->
<cfset MaxRows = 10>
<!-- Initialise all fields if they do not exist -->
<cfparam name="start" default="1">
<cfparam name="us_id" default="">
<cfparam name="us_dp_code" default="">
<cfparam name="us_name" default="">
<cfparam name="us_address_line_1" default="">
<cfparam name="us_access" default="">


<!-- What is the next row to start at -->
<cfset PrevStart = Start - MaxRows>
<cfset Nextstart = start + MaxRows>

<!-- Previous Button Code -->
<cfif prevstart GTE 1>
<cfoutput>
<form action="usercreation.cfm" method="post">
<input type="hidden" name="start" value="#PrevStart#">
<input type="hidden" name="us_id" value="#US_ID#">
<input type="hidden" name="us_dp_code" value="#US_DP_CODE#">
<input type="hidden" name="us_name" value="#US_NAME#">
<input type="hidden" name="us_address_Line_1" value="#US_ADDRESS_LINE_1#">
<input type="hidden" name="us_access" value="#US_Access#">
<input type="submit" value="<< Previous #MaxRows# Records">
</form>
</cfoutput>
</cfif>
</td>
<td>
<form action="" method="post">
<input type="submit" value="Update User Record">
</form>
</td>
<td>
<form action="viewall.cfm" method="post">
<input type="submit" value="View All Records">
</form>
</td>
<td>
<!-- Next Button Code -->
<cfoutput>
<form action="usercreation.cfm" method="post">
<input type="hidden" name="start" value="#NextStart#">
<input type="hidden" name="us_id" value="#US_ID#">
<input type="hidden" name="us_dp_code" value="#US_DP_CODE#">
<input type="hidden" name="us_name" value="#US_NAME#">
<input type="hidden" name="us_address_Line_1" value="#US_ADDRESS_LINE_1#">
<input type="hidden" name="us_access" value="#US_Access#">
<input type="submit" value="Next #MaxRows# Records >> ">
</form>
</cfoutput>
</center>
</td>
</tr>
</table>
</body>
</html>
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question