Exercise 5: Linking The Trip Edit Page To The Main Page - MACROMEDIA COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX Getting Started

Building coldfusion mx applications
Table of Contents

Advertisement

Reviewing the code
The following tables describes the
Code
<cfif not isdefined("form.tripID")>
<cfinsert datasource="CompassTravel"
tablename="Trips">
<cflocation url="tripdetail.cfm">
<cfelse>
<cfupdate datasource="CompassTravel"
tablename="Trips">
<cflocation
url="tripdetail.cfm?ID=#Form.tripID#">
</cfif>
To update the database using a cfupdate tag:
Open the tripeditaction.cfm file in the my_app directory in your editor.
1.
Add the following code before the
2.
<!--- Update the database --->
<cfif isOk EQ "Yes">
<cfif isdefined("form.tripID")>
<cfupdate datasource="CompassTravel" tablename="trips">
<cflocation url="tripdetail.cfm?ID=#Form.tripID#">
<cfelse>
<cfinsert datasource="CompassTravel" tablename="TRIPS">
</cfif>
<cfoutput>You have added #Form.TripName# to the trips database.
</cfoutput>
</cfif>
Save the file.
3.
For more information about adding data to a database using the
MX Developer's Guide.

Exercise 5: Linking the Trip Edit page to the main page

As discussed in
"Lesson 7: Validating Data to Enforce Business Rules" on page
page for the maintenance buttons on the main page is maintenanceaction.cfm
added code for the Search and Delete buttons. In this exercise, you add code for the Add and Edit
buttons.
To link the Add and Edit buttons on the Trip Detail page:
Open the maintenanceaction.cfm file in the my_app directory in your editor.
1.
Locate the
2.
</cfif>
138
Chapter 12: Lesson 9: Enabling Database Maintenance
cfinsert
</body>
<cflocation url="tripdetail.cfm">
tag at the end of the file.
and
code:
cfupdate
Explanation
The
function determines whether
IsDefined
the hidden field
action page from the tripedit.cfm page. If there
is a current trip, the
True. When there is no current trip, the
statement is True. When the
True, the
cfinsert
page appears with the updated trip. If the
statement evaluates to False, the
statement executes and the first trip appears in
the main page.
tag at the end of the file:
cfupdate
was passed to the
tripID
function returns
IsDefined
statement is
cfif
tag executes and the main
cfinsert
tag, see ColdFusion
103, the action
You previously
.
cfif
cfif

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Colfusion mx 7 - installing and using coldfusion mx

Table of Contents