Joby, in your action file you want to do something along the lines of this.
<cfset guestArray = #ArrayNew(1)#>
<!--- Loop to set the Guests Names to the value selected --->
<cfloop index="n" from="1" to="#nbr_guests#">
<!---- Use the Evaluate command to combine the text name with the appropriate
number --->
<cfset guestArray[#n#] = Evaluate("guest_name_" & #n#)>
</cfloop>
Or you could do that while looping through your query... just depend on your
preference. I'm not sure it will
work, but you could probably throw in a <cfif isDefined(Evaluate("guest_name_" &
#n#))> to ensure that there it is
defined.
I hope this helps you out.
Ted Parton
Joby Bednar wrote:
> I need some help please!
>
> I have a form that asks for # of guests. It then goes to a page that
> generates a form for each guest and names the fields "name_first_1",
> "name_first_2", etc... I need to figure out some way to do a <cfparam> for
> each possible name in case it was left blank, and then add each guest's info
> into a database. The problem I have is how do I loop to add the fields into
> the database with the proper info? I'm trying to put them into an array and
> then use the array for the query.
>
> This is something like what I'm trying to do, but I can't figure out how to
> get it to work:
> <cfloop from="1" to="#form.guests_number#" index="gnum"> <cfoutput>
> <cfparam name="form.guest_salutation_#gnum#" default=""> <cfparam
> name="form.guest_name_first_#gnum#" default=""> </cfoutput></cfloop>
> <cfloop from="1" to="#form.guests_number#" index="gnum"><cfset
> temp_salutation[gnum] = ???><cfset temp_name_first[gnum] = ???></cfloop>
> <cfloop from="1" to="#form.guests_number#" index="gnum"><cfquery
> datasource="xxx"> INSERT INTO Guests (guest_salutation,guest_name_first)
> VALUES
> ('#temp_salutation[gnum]#','#temp_name_first[gnum]#')</cfquery></cfloop>
> Joby Bednar
> Director of Internet Design
> iNEOgroup.com
> http://www.ineogroup.com
> Fusing your Dreams and the Web, Together as One
> [EMAIL PROTECTED]
> Cell: 949-283-5138
> Personal Fax: 208-485-1170
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists