If you want a form field, why use Evaluate? Just treat the form field as a
struct key.

 <cfset thelist = "">
 <cfloop from="1" to="3" index="id">
        <cfset tempvalue = "fieldnum#id#">
        <cfset thevalue = Form[tempvalue]>
        <cfset thelist = ListAppend(thelist, thevalue)>
 </cfloop>

or even shorter...

 <cfset thelist = "">
 <cfloop from="1" to="3" index="id">
        <cfset thevalue = Form["fieldnum#id#"]>
        <cfset thelist = ListAppend(thelist, thevalue)>
 </cfloop>

=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Macromedia

Email   : [EMAIL PROTECTED]
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda

> -----Original Message-----
> From: Dylan Bromby [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 24, 2001 12:22 PM
> To: CF-Talk
> Subject: RE: Dynamic variable names
>
>
> yes you can do it. i use Evaluate() with dynamic values all the time.
>
> try removing the " from "#id#". if that doesn't work (it should), try
> something like:
>
> <cfset thelist = "">
> <cfloop from="1" to="3" index="id">
>       <cfset tempvalue = form.fieldnum&#id#>
>       <cfset thevalue = Evaluate(tempvalue)>
>       <cfset thelist = ListAppend(thelist, thevalue)>
> </cfloop>
>
> -----Original Message-----
> From: Andy Ewings [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, May 24, 2001 8:23 AM
> To: CF-Talk
> Subject: Dynamic variable names
>
>
> Can you have dynamic variable names in CF?....e.g in an action page could
> you have something like -
>
> <cfset thelist = "">
> <cfloop from="1" to="3" index="id">
>       <cfset thevalue = Evaluate(form.fieldnum & "#id#")>
>       <cfset thelist = ListAppend(thelist, thevalue)>
> </cfloop>
>
> where there are form fileds fieldnum1, fieldnum2, and fieldnum3.
>
> I have tried this but it doesn't work.....I thought you might be
> able to use
> the Evaluate function in this way as this works (from the Forta book):
>
> <cfset x = "Array">
> <cfset EVALUATE("p = " & x & "New(1)")>
>
> This creates a new array stored in the variable p
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to