User Guide

Table Of Contents
696 Chapter 29: Creating Forms in Macromedia Flash
One example that might use a repeater is a form that lets a teacher select a specific class and
update the student grades. Each class can have a different number of students, so the form must
have a varying number of input lines. Another example is a shopping cart application that
displays the product name and quantity ordered and lets users change the quantity.
The following example uses the
cfformgroup tag with a repeater type attribute value to
populate a form. It creates a query, and uses the repeater to iterate over a query and create a
firstname and lastname input box for each row in the query.
<cfif IsDefined("Form.fieldnames")>
<cfdump var="#form#" label="form scope">
<br><br>
</cfif>
<cfscript>
q1 = queryNew("id,firstname,lastname");
queryAddRow(q1);
querySetCell(q1, "id", "1");
querySetCell(q1, "firstname", "Rob");
querySetCell(q1, "lastname", "Smith");
queryAddRow(q1);
querySetCell(q1, "id", "2");
querySetCell(q1, "firstname", "John");
querySetCell(q1, "lastname", "Doe");
queryAddRow(q1);
querySetCell(q1, "id", "3");
querySetCell(q1, "firstname", "Jane");
querySetCell(q1, "lastname", "Doe");
queryAddRow(q1);
querySetCell(q1, "id", "4");
querySetCell(q1, "firstname", "Erik");
querySetCell(q1, "lastname", "Pramenter");
</cfscript>
<cfform name="form1" format="flash" height="220" width="450">
<cfselect label="select a teacher" name="sel1" query="q1" value="id"
display="firstname" width="100" />
<cfformgroup type="repeater" query="q1">
<cfformgroup type="horizontal" label="name">
<cfinput type="Text" name="fname" bind="{q1.currentItem.firstname}">
<cfinput type="Text" name="lname" bind="{q1.currentItem.lastname}">
</cfformgroup>
</cfformgroup>
<cfinput type="submit" name="submitBtn" value="Send Data" width="100">
</cfform>
Creating complex forms with accordion and tab navigator containers
The
accordion and tabnavigator attributes of the cfformgroup tag let you construct complex
forms that would otherwise require multiple HTML pages. With accordions and tab navigator
containers, users can switch among multiple entry areas without submitting intermediate forms.
All data that they enter is available until they submit the form, and all form elements load at one
time.