Yes, the button submits the form and the handler does the redirect. I had a
'previous' and 'next' hyperlink using <a href> but sometimes it would save data
and other times it wouldn't. Also, the page displays 25 records at a time so
the links were passing the start row and total number of rows to display the
previous or next 25 using onClick events.
I changed to buttons and used javascript, still using the onClick event.
Here's the important parts of the code:
<!--- Define variables --->
<cfparam name="StartRow" default="1">
<cfparam name="DisplayRows" default="25">
<!--- Set a variable to hold the record number of the last record to output on
the current page. --->
<cfset ToRow = StartRow + (DisplayRows - 1)>
<cfif ToRow GT getData.RecordCount>
<cfset ToRow = getData.RecordCount>
</cfif>
<!--- create the values for the next and previous rows to be returned --->
<cfset Next = StartRow + DisplayRows>
<cfset Previous = StartRow - DisplayRows>
<cfset Current = StartRow>
These are the hidden form fields:
<form name="frmSubmit" action="location-list.cfm?ProcessLevel=#ProcessLevel#"
method="post">
<input type="hidden" name="Records" value="#getData.recordcount#">
<input type="hidden" name="ProcessLevel" value="#ProcessLevel#">
<input type="hidden" name="FormAction" value="Save">
<input type="hidden" name="n" value="#sNext#">
This is the javascript that runs when you click a button:
<script language="javascript">
function doSubmit(strNext)
{
var frm = document.frmSubmit;
frm.FormAction.value="SAVE";
frm.n.value = strNext;
}
</script>
These are the buttons:
<!--- Create a button to go back to the previous set of records in the record
set. --->
<cfif Previous GTE 1>
<input type="button" name="btnBack" value="Save and Previous"
onClick="doSubmit(#sPrevious#);"/>
<cfelse>
<span class="Default">Previous Records</span>
</cfif>
<!--- Create a button if there are more records in the record set that haven't
yet been displayed. --->
<cfif Next LTE getData.RecordCount>
<input type="button" name="btnNext" value="Save and Next"
onClick="doSubmit(#sNext#);"/>
</cfif>
So, the buttons call sPrevious and sNext and I thought I could do something
like this:
sPrevious=<cflocation
url="location-list.cfm?StartRow=#Previous#&ProcessLevel=#ProcessLevel#"
addtoken="no">
sNext = <cflocation
url="location-list.cfm?StartRow=#Next#&ProcessLevel=#ProcessLevel#"
addtoken="no">
But as you know, you can't nest a <cflocation> inside a <cfset>. Hence, I'm
stuck.
I've done this in ASP exactly this way and it works great. I just declare
sPrevious and sNext and then throw some quotes around the URLs I want each to
go to and bam - you go there.
Thanks for looking at it.
Renee
>Can you expand your explanation of what you are trying to do or paste some
>code?
>
>Are you using the button to submit a form and the handler processes the form
>and does the redirect>
>
>
>Mike Chytracek
>Managing Partner
>Ignite Solutions
>p. 312.239.0032
>c. 815.302.3507
>f. 866.839.7896
>
>
>
>
>
>I want to set a value (sNext) which is used on a button and when clicked
>will redirect to another page. I've figured out I can't nest <cflocation>
>inside <cfset> so how do I do it?
>
>Thanks!
>Renee
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;160198600;22374440;w
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:3384
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15