• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Passing form variables to a template page.

New Here ,
Sep 02, 2008 Sep 02, 2008

Copy link to clipboard

Copied

I created a form page which passes a form variable name 'orderNo'. When it hits the action page a <cfif>
statement deduces whether it has been used and exists in a database record. The <cferror> than
send the user to the (cferror assigned template page). I would like the user to see the form.orderNo variable they entered on the template page.

Code inside action page which test the form variable against records
<!--- query the database to find a match for the form variable 'orderNo'--->

<cfquery name="GetMatch" datasource="dbMHAM">
SELECT OrderNo
FROM tblMham
WHERE OrderNo = <cfqueryparam value="#form.orderNo#" cfsqltype="CF_SQL_LONGVARCHAR">
</cfquery>


<!--- if the record count for the order number is '0' then request the template
page to provide information to the user about the number already existing
in a record of the database--->

<cfif GetMatch.recordCount GT 0>
<cferror type = "request" template= OrderNo_ValidationPage.cfm>
<cfabort showerror="order number already used">

Template page output

<cfoutput>#orderNo#</cfoutput> you entered is found in a posted record.<br>
Hit the<strong> Internet explorer back button</strong> review the survey and enter a new number<br>
or edit the with the same order number you tried to use

Text
TOPICS
Advanced techniques

Views

330

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 02, 2008 Sep 02, 2008

Copy link to clipboard

Copied

For your specific problem, set the form variable to a session variable and use cflocation to go to the new page instead of cferror.

On a more general note, what kind of application do you have where the users have to come up with their own unique order numbers?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 02, 2008 Sep 02, 2008

Copy link to clipboard

Copied

LATEST
Hi Dan,
thanks for getting back to me. The application uses the orderNo as a unique/primary key number. It is a factory order number used for product we create. We are tracking the makeup of the equipment for the machine history.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation