I'd suggest tracking the number of rows and dynamically generating the form
fields. For example, the following code starts with 1 row (containing
"Name" and "Age" fields) and supports the addition of an unlimited number of
rows (note: this code is not tested and very likely has errors given that
I'm writing it off the top of my head at 2 in the morning):
<!--- Initialize (& increment) rowCount --->
<CFPARAM NAME="FORM.rowCount" DEFAULT="1">
<CFIF IsDefined("FORM.Add")>
<CFSET FORM.rowCount = FORM.rowCount + 1>
</CFIF>
<!--- Initialize the form field values --->
<CFLOOP FROM="1" TO="#FORM.rowCount#" INDEX="cnt">
<CFPARAM NAME="FORM.Name_#cnt#" DEFAULT="">
<CFPARAM NAME="FORM.Age_#cnt#" DEFAULT="">
</CFLOOP>
<FORM>
<CFOUTPUT><INPUT TYPE="Hidden" NAME="rowCount"
VALUE="#FORM.RowCount#"></CFOUTPUT>
<TABLE>
<TR>
<TD>Name</TD>
<TD>Age</TD>
</TR>
<!--- Display the rows --->
<CFLOOP FROM="1" TO="#FORM.rowCount#" INDEX="cnt">
<CFOUTPUT>
<TR>
<TD><INPUT TYPE="Text" NAME="Name_#cnt#"
VALUE="#Evaluate("FORM.Name_#cnt#")#">
</TD>
<TD><INPUT TYPE="Text" NAME="Age_#cnt#"
VALUE="#Evaluate("FORM.Age_#cnt#")#">
</TD>
</TR>
</CFOUTPUT>
</CFLOOP>
<TR>
<TD><INPUT TYPE="Submit" NAME="Add" VALUE="Add"></TD>
<TD><INPUT TYPE="Submit" NAME="Save" VALUE="Save"></TD>
</TR>
</TABLE>
</FORM>
The code doesn't take into account how you'd submit all the data for saving.
But you could handle this either with JavaScript changing the form action on
button click or with Cold Fusion by redirecting (or including, depending on
your application flow) another file somewhere. Anyway, I hope this helps.
--
Mosh Teitelbaum
evoch, LLC
Tel: (301) 625-9191
Fax: (301) 933-3651
Email: [EMAIL PROTECTED]
WWW: http://www.evoch.com/
> -----Original Message-----
> From: Russ [mailto:russ@;unrealisticexpectations.com]
> Sent: Wednesday, October 23, 2002 1:37 AM
> To: CF-Talk
> Subject: Adding a row..
>
>
> All,
>
> My application has "line items" that are stored in a database for a
> project.
>
> When you enter the application page, you start with a blank line item.
> You enter your information, you can perform a calculation and then you
> have the option to "Save" the project or you can "Add a Row".
>
> Saving simply updates the db and then sends you on your merry way.
>
> Adding a row, on the other hand, updates all current Line Items and then
> returns with a new blank line.
>
> Additionally, there are fields that calculate certain titles from the
> line items to give dollar amounts, etc.
>
> The issue I'm having is that I cannot figure out the best approach to
> adding this new line item "row" to my project.
>
> Does anyone have any examples of this type of application or where
> they've done something similar?
>
> Thanks,
>
> Russ Unger
> Managing Partner
> Blue Chrome Design
> www.bluechromedesign.com
> 312.593.4260 :office
> 877.433.8427 :pager
> 312.873.4033 :fax
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm