User Guide

Enhancing the Trip Maintenance application 87
When a query variable is referenced within a cfoutput block, the qualifying query_name is
assumed to be the query identified in the QUERY attribute of the
cfoutput tag and does not
need the
qualifier query_name. That is why the CurrentRow variable is unqualified in the
previous modulus code example.
For more information about using the modulus function or query variables in ColdFusion
applications, see Developing ColdFusion MX Applications.
Exercise: formatting the display
In this exercise, you format the currency and date fields in the Trip Search Results page and the
Trip Detail page. Additionally, you modify the Trip Search Results page to alternate the
background color of the result table rows.
To format the table:
1 To format the Trip Detail page dollar and date fields, open the tripdetail.cfm in the my_app
directory in your editor and make the following changes:
2 To format the currency and date fields on the Trips Search Results page, open the
tripsearchresult.cfm in your editor and make the same changes for departureDate,
returnDate, and price as in step 1.
3 To alternate the background color of the rows of the search results table, delete the table row
tag
<tr> that immediately follows the <cfoutput query="TripResult">, and replace it with
the following code:
<cfif CurrentRow Mod 2>
<cfset BackColor="White">
<cfelse>
<cfset BackColor="Yellow">
</cfif>
<TR bgcolor= #BackColor#>
4 Save the files then open your browser and navigate to the tripsearch.cfm page in the my_app
directory. Again, enter Begins With and C in the location search criteria, and click Search.
Existing code Change to
#departureDate# #dateformat(departureDate, "mm/dd/yyyy")#
#returnDate# #dateformat(returnDate, "mm/dd/yyyy")#
#price# #dollarformat(price)#
#baseCost# #dollarformat(baseCost)#