Reviewing the code
The following table describes the code:
Code
<cfif isDefined("Form.submit")>
<cfparam name="Form.itemID"
default="">
<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>
102
Chapter 4: Using Expressions and Pound Signs
Description
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.
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).
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).
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers