Instead of:
NAME = #Evaluate("tempvar")#<br>
Remove the quotes:
NAME = #Evaluate(tempvar)#<br>
The first line is evaluating the string expression "tempvar" which returns
the field names. By removing the quotes you are telling the Evaluate
function to evaluate the contents of the variable Tempvar, i.e. evaluate the
fieldnames which results in the values.
HTH
STeve
> -----Original Message-----
> From: Paul Sinclair [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 01, 2000 13:11
> To: [EMAIL PROTECTED]
> Subject: RE: <CFLOOP>'ing FORM Field Names Problem
>
>
> Jeff,
>
> Thanks for the note. I must be really dense or something. I tried this:
>
> <cfset loopnumber = (#URL.PersonsAttending# - 1)>
>
> <cfloop index="PersonsAttending" from="1" to="#loopnumber#" step="1">
>
> <cfset tempvar='full_name_'&'#PersonsAttending#'>
>
> NAME = #Evaluate("tempvar")#<br>
>
> </cfloop>
>
> When I process this, the Evaluate function just tells me what the name of
> the field is. So the output that I receive is:
>
> NAME - full_name_1
> NAME - full_name_2
> NAME - full_name_3
>
> In other words, it gives me the name of the form fields, but not the value
> that was entered. What I want it to output is:
>
> NAME - John Doe
> NAME - Joe Smith
> NAME - Mary Jones
>
> How can I make it so that in the loop, #FORM.Evaluate("tempvar")# becomes
> #FORM.full_name_1# (#FORM.full_name_2#, etc.)? In other words -
> shows me the
> value entered, not the field name.
>
> Thanks for any more help!
>
> Paul Sinclair
>
>
>
>
>
> > -----Original Message-----
> > From: Jeff Beer [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, August 01, 2000 12:21 AM
> > To: [EMAIL PROTECTED]
> > Subject: RE: <CFLOOP>'ing FORM Field Names Problem
> >
> >
> > Change it to:
> >
> > NAME = #Evaluate("tempvar")#
> >
> > and it should work. You don't really need to set the temp variable.
> >
> > Remember, there is no variable named "form.tempcomment". You
> are already
> > past the rebuilding of the form name, which was done with:
> >
> > <cfset tempvar='full_name_'&'#PersonsAttending#'>
> >
> > At that point, tempvar = the value of #form.full_name_x#, where x is the
> > current loop index.
> >
> > You could even shorten the code by using something like:
> >
> > <cfloop ...>
> > NAME = EVALUATE('full_name_'& PersonsAttending)
> > </cfloop>
> >
> > This will print the value you want. You would need to assign a
> > variable in
> > order to really use that value.
> >
> > <cfloop ...>
> > <cfset myNAME = EVALUATE('full_name_'& PersonsAttending)>
> > <cfquery ...>
> > INSERT INTO MyTable (full_name)
> > VALUES ('#myName#')
> > </cfquery>
> > </cfloop>
> >
> > Good luck!
> >
> > Jeff
> >
> > -----Original Message-----
> > From: Paul Sinclair [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, July 31, 2000 10:52 PM
> > To: [EMAIL PROTECTED]
> > Subject: RE: <CFLOOP>'ing FORM Field Names Problem
> >
> >
> > Dana,
> >
> > Thanks for your suggestion and code snippet. I'm still not getting it to
> > work though. Here's what I've tried:
> >
> >
> > <cfloop index="PersonsAttending" from="1" to="#loopnumber#" step="1">
> >
> > <cfset tempvar='full_name_'&'#PersonsAttending#'>
> >
> > <cfset tempcomment='#Evaluate("tempvar")#'>
> >
> > Name = #FORM.tempcomment#
> >
> > </cflooop>
> >
> >
> > When I run this, I get the same error I've been having:
> >
> > --------Error message follows---------------------
> > Error Diagnostic Information
> > An error occurred while evaluating the expression:
> >
> > #FORM.tempcomment#
> >
> > Error resolving parameter FORM.TEMPCOMMENT
> >
> > The specified form field cannot be found. This
> > problem is very likely due to the fact that you
> > have misspelled the form field name.
> > --------End Error Message-------------------------
> >
> > I can't figure out how to get CF to understand that where I have
> > #FORM.tempcomment#, I want it to read the variable tempcomment
> so that it
> > comes out as #FORM.full_name_1# (or #FORM.full_name_2#, etc.)
> >
> > How do I cram this thing down CF's throat?
> >
> > Thanks for any more suggestions!
> >
> > Paul Sinclair
> >
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Dana Larose [mailto:[EMAIL PROTECTED]]
> > > Sent: Monday, July 31, 2000 6:25 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: <CFLOOP>'ing FORM Field Names Problem
> > >
> > >
> > > 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.
>
>
> ------------------------------------------------------------------
> ----------
> --
> 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.
----------------------------------------------------------------------------
--
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.