If you remember that the form scope is a structure, it is real easy.

Keeping that in mind,
evaluate("form.childoffer_" & i) [or even
evaluate("form.childoffer_#i#")]

becomes
structfind(form,"childoffer_#i#")

And if you take it to the next step, for other things, then instead of
an array of structures, you can use structures of structures.

So myarray[i].mystruct.key

becomes structfind(mystruct,"key_#i#)

I personally try to stay away from evaluate NOT ONLY because it looks
through the scope stack in the "preferred" order of lookup
(variables,form,url, etc) and does take an almost immeasurable longer
time to find the var that structfind does, BUT ALSO because it makes
it easier for someone else to read the code later..




On Jul 16, 11:22 am, Sammy Larbi <[EMAIL PROTECTED]> wrote:
> Mark Davis wrote, On 7/16/2007 11:16 AM:
>
>
>
> > Nevermind...I figured it out...
>
> > <cfloop from="1" to="#counter#" index="i">
>
> > <cfset session.PARCAdmin.ChildOffer[#counter#] = structnew()>
>
> > <cfset session.PARCAdmin.ChildOffer[#counter#].childOfferName =
> > evaluate("form.childoffer_" & i)>
>
> > <cfset session.PARCAdmin.ChildOffer[#counter#].childOfferRelationship
> > = Evaluate("form.relationshiptype_" & i)>
>
> > </cfloop>
>
> Generally people shy away from using evaluate and instead would access
> it as someone mentioned before:
>
> form["relationshiptype_#i#"] or form["relationshiptype_" & i]
>
> Cheers,
> Sam
>
>
>
> > Need more coffee
>
> > Mark Davis
> > Cricket Communications
> > Software Engineer III
>
> > 303-734-7694 (w)
>
> > ------------------------------------------------------------------------
>
> > *From:* Mark Davis
> > *Sent:* Monday, July 16, 2007 10:04 AM
> > *To:* '[email protected]'
> > *Subject:* string concatenation and Evaluate
>
> > Alright...not sure why I am having such trouble making this work...
>
> > I have a set of x number of form variables named as such...
>
> > Form.childOffer_1
>
> > Form.childOffer_2
>
> > .....
>
> > After form submission, I need to loop thru those and set the values
> > into different structs, like this...
>
> > <cfloop from="1" to="#form.counter#" index="i">
>
> > <cfset session.PARCAdmin.ChildOffer[#counter#] = structnew()>
>
> > <cfset session.PARCAdmin.ChildOffer[#counter#].childOfferName = #No
> > Workie Here#>
>
> > </cfloop>
>
> > The value needs to have form.childOffer concatenated with the value of
> > I, then evaluated to get the value.
>
> > Any suggestions? I know I am missing something obvious.
>
> > Mark Davis
> > Cricket Communications
> > Software Engineer III
>
> > 303-734-7694 (w)- Hide quoted text -
>
> - Show quoted text -


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Houston ColdFusion 
Users' Group" discussion list.
To unsubscribe, send email to [EMAIL PROTECTED]
For more options, visit http://groups.google.com/group/houcfug?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to