MACROMEDIA COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION MX Getting Started page 103

Building coldfusion mx applications
Table of Contents

Advertisement

The cfselect tag
The
tag is an improved version of the HTML
cfselect
tags, the
tag provides the
cfselect
entered. Using the
cfselect
field data entry as follows:
<!--- Field: eventType --->
<tr>
<td valign="top">Type of Event
</td>
<td>
<cfselect size="1" name="eventType" required="Yes"
message="Type of event must be selected.">
<cfoutput query="GetEvents">
<option value="#GetEvents.eventTypeID#">
#GetEvents.eventType#
</option>
</cfoutput>
</cfselect>
</td>
</tr>
Exercise: use eventtypes table to load event types
Do the following steps to modify the Trip Edit page to display a list of event types from the
eventtypes table and add validation.
To display a list of event types from the eventtypes table and add validation:
View the tripedit.cfm page in a browser. Select the event types drop-down list. Notice that only
1
three event types appear in the list.
Open the tripedit.cfm in the my_app directory in your editor.
2
Add the following code above the <html> tag:
3
<cfquery name="GetEvents" datasource="CompassTravel">
SELECT eventType, eventTypeID
FROM eventtypes
</cfquery>
Replace the following eventtypes code lines:
4
<cfselect size="1" name="eventType" required="Yes"
message="Type of event must be selected.">
<option value="1" selected>Surfing</option>
<option value="2">Mountain Climbing</option>
<option value="3">Mountain Biking</option>
</cfselect>
with these lines:
<cfselect size="1" name="eventType" required="Yes"
message="Type of event must be selected.">
<cfoutput query="GetEvents">
<option value="#GetEvents.eventTypeID#">
#GetEvents.eventType#
</option>
</cfoutput>
</cfselect>
and
required
message
tag and the preceding
Developing code to validate data and enforce business rules
tag. Like other ColdFusion form
select
attributes that validate the data
, you can implement the
cfquery
eventType
103

Advertisement

Table of Contents
loading
Need help?

Need help?

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

This manual is also suitable for:

Coldfusion mx

Table of Contents