MACROMEDIA COLDFUSION 5 - INSTALING AND CONFIGURING SERVER Manuel d'instructions Page 121

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 154
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 120
Developing code to validate data and enforce business rules 111
<!--- 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:
1 View the tripedit.cfm page in a browser. Select the event types drop-down list. Notice
that only three event types appear in the list.
2 Open the tripedit.cfm in the my_app directory in your editor.
3 Add the following code above the <html> tag:
<cfquery name="GetEvents" datasource="CompassTravel">
SELECT eventType, eventTypeID
FROM eventtypes
</cfquery>
4 Replace the following eventtypes code lines:
<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>
5 View the tripedit.cfm page in a browser. Select the event types drop-down list. Notice
that all seven event types appear in the list.
Vue de la page 120
1 2 ... 116 117 118 119 120 121 122 123 124 125 126 ... 153 154

Commentaires sur ces manuels

Pas de commentaire