One of the guys here came up with a hack to do this. Wrap an Evaluate
around the expression, and that seemed to work for us in a similar
situation. We'll not sure if this is clean ColdFusion or not, but it seems
to get the job done.
Here is a sample:
<cfset tempvar='full_name_'&'#PersonsAttending)#'>
<cfset tempcomment='#Evaluate("#tempvar#")#'>
Now tempcomment contains the value that full_name_3 from the previous page
did. Assuming PersonsAttending is 3.
Dana Larose
Software Engineer
Canadian Web Design & Consulting Inc.
A: 701-281 McDermot Avenue (McDermot & King)
P: 204-946-5155
C: 204-228-0477
F: 204-946-5156
E: [EMAIL PROTECTED]
W: http://www.cdnwebdesign.com
> -----Original Message-----
> From: Paul Sinclair [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 31, 2000 3:28 PM
> To: [EMAIL PROTECTED]
> Subject: <CFLOOP>'ing FORM Field Names Problem
>
>
> I've got a form that is dynamically created based on how many people are
> being registered for an event. For example, if a person wants to
> register 4
> people, I use <CFLOOP> to create a form with fields for the entry of 4
> peoples' names. I.e.:
>
>
>
> <html>
>
> Person 1: <input type="text" name="full_name">
>
> <cfif PersonsAttending GT 1>
>
> <cfset loopnumber = (#URL.PersonsAttending# - 1)>
>
> <cfloop index="PersonsAttending"
> from="1"
> to="#loopnumber#"
> step="1">
>
> Next Person: <input type="text" name="full_name_#PersonsAttending#">
>
> </cfloop>
>
> </cfif>
>
> </html>
>
>
> The effect of this is that the name of the form fields changes during each
> step of the loop, such as:
>
> full_name_1 (where the index of "PersonsAttending" is 1)
> full_name_2 (where the index of "PersonsAttending" is 2)
> full_name_3 (where the index of "PersonsAttending" is 3)
>
> and so on.
>
> This works fine. But I'm having trouble in the template that receives the
> information. I want to <CFMAIL> the registration info out. I can get the
> first person's info fine, but for the fields where the field name has been
> incremented during looping, I can't figure out how to capture the fields.
>
> The <cfmail> looks something like this:
>
> <html>
>
> <cfmail to="me" from="you" subject="Registration">
>
> Registration Received for:
>
> #FORM.Full_Name#
>
> <cfif PersonsAttending GT 1>
>
> Other People Registered:
>
> <cfset loopnumber = (#URL.PersonsAttending# - 1)>
>
> <cfloop index="PersonsAttending" from="1" to="#loopnumber#" step="1">
>
> #FORM.Full_Name#_#PersonsAttending#
> ^^^^^^^^^^^^^^^^^^^
> </cfmail>
>
> </html>
>
> I've put "up carets" (^) under the spot where I'm having trouble. What I
> need to do is concatenate "_#PersonsAttending#" to
> #FORM.Full_Name#, but it
> has to be inside the # signs. I can't figure out how to do it. I've tried
> several variations and also tried using <cfset>. Nothing seems to work.
>
> How do I get it so that the field from which the information is drawn gets
> incremented up with each loop? In the case where 4 people are
> registered, I
> need to get it so that the <cfloop> portion winds up with loops for:
>
> #FORM.Full_Name_1#
> #FORM.Full_Name_2#
> #FORM.Full_Name_3#
>
> I can't figure out how to get the FORM field's name changed using the
> <cfloop>. I'm sure it's something simple. But right now it is escaping me.
>
> Thanks for taking a look at this for me.
>
> Paul Sinclair
>
> ------------------------------------------------------------------
> ------------
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf
_talk or send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.