102
Chapter 4: Using Expressions and Pound Signs
Reviewing the code
The following table describes the code:
Code
Description
<cfif isDefined("Form.submit")>
Run the CFML on this page only if it is called by submitting a
form. This is not needed if there are separate form and
action pages, but is required if the form and action page
were one ColdFusion page.
<cfparam name="Form.itemID"
default="">
Set the default Form.itemID to the empty string. This
prevents ColdFusion from displaying an error if the user
clears all check boxes before submitting the form (so no
product IDs are submitted).
<cfoutput>
You have ordered the following
items:<br>
<br>
<cfloop index="i" list=
"#Form.itemID#">
ProductName:
#Form["product_" & i]#<br>
Product Code:
#Form["sku_" & i]#<br>
Quantity:
#Form["qty_" & i]#<br>
<br>
</cfloop>
</cfoutput>
</cfif>
Display the name, SKU number, and quantity for each
ordered item.
The form page posts Form.itemID as a list containing the
value attributes of all the check boxes. These attributes
contain the shopping cart item IDs for the selected cart
items. Use the list values to index a loop that outputs each
ordered item.
Use associative array notation to access the Form scope as
a structure and use expressions in the array indexes to
construct the form variable names. The expressions consist
of a string containing the field name’s field type prefix (for
example, "sku_"), concatenated with the variable i, which
contains the shopping cart ItemID number (which is also the
loop index variable).
Summary of Contents for COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......