Tomek thanks, when i use evaluate like:
<cfloop index="i" from="1" to="6">
<cfif #form[stprops_polling.objectid]# EQ "#i#">
<cfset evaluate("stprops_pollingvote.answer" & "#i#") = "1">
</cfif>
</cfloop>
i get an error:
15:40:31.031 - Template Exception - in C:\Inetpub\wwwroot\farcry\core
\packages\rules\rules.cfc : line 133
Cannot assign a value to a function.
Sean, also thanks, when i use your suggestion:
<cfloop index="i" from="1" to="6">
<cfif #form[stprops_polling.objectid]# EQ "#i#">
<cfset variables[ "stprops_pollingvote.answer" & i ] = "1">
</cfif>
</cfloop>
the structure not gets the value assigned, when i use this:
<cfif #form[stprops_polling.objectid]# EQ "1">
<cfset stprops_pollingvote.answer1 = "1">
<cfelseif #form[stprops_polling.objectid]# EQ "2">
<cfset stprops_pollingvote.answer2 = "1">
<cfelseif #form[stprops_polling.objectid]# EQ "3">
<cfset stprops_pollingvote.answer3 = "1">
<cfelseif #form[stprops_polling.objectid]# EQ "4">
<cfset stprops_pollingvote.answer4 = "1">
<cfelseif #form[stprops_polling.objectid]# EQ "5">
<cfset stprops_pollingvote.answer5 = "1">
<cfelseif #form[stprops_polling.objectid]# EQ "6">
<cfset stprops_pollingvote.answer6 = "1">
</cfif>
it works fine, and although the structure is the same in output, in
code view it's of course more neat to have it in a loop.
So just leave it like this or is it possible to do so in a loop??
Thanks both!
On Oct 24, 2:06 pm, Sean Coyne <[EMAIL PROTECTED]> wrote:
> dont use evaluate. Try:
>
> <cfset i = '1' />
> <cfset variables[ "stprops_pollingvote.answer" & i ] = "1">
> <cfdump var="#variables#" />
>
> just worked for me. What is "i" set to?
>
> On Oct 23, 9:38 pm, "Tomek Kott" <[EMAIL PROTECTED]> wrote:
>
> > i think something like
> > <cfset evaluate("stprops_pollingvote.answer" & "#i#") = "1"> might work. If
> > that doesn't, I think generally you need to use evaluate for something like
> > that. That's the only way I can think of to get something like that done
> > though.
>
> > Best,
>
> > Tomek
>
> > On Thu, Oct 23, 2008 at 8:02 PM, Marco van den Oever <
>
> > [EMAIL PROTECTED]> wrote:
>
> > > I loop over
>
> > > <cfset variables[ "stprops_pollingvote.answer" & "#i#" ] = "1">
>
> > > and when the selected form value is equal to the number in the index
> > > it sets the above item, so if option 1 was selected then
> > > stprops_pollingvote.answer1 is cfset to 1.
>
> > > Just read "You cannot use a dynamic variable when you create a
> > > structure implicitly." at cfm docs, so that implies you have to work
> > > with cfif statements and cfset the structure items static, or is there
> > > some other farcry trick available?
>
> > > On Oct 24, 1:52 am, Marco van den Oever <[EMAIL PROTECTED]>
> > > wrote:
> > > > I want to set up structure items by a loop:
>
> > > > <cfset variables[ "stprops_pollingvote.answer" & "#i#" ] = "1">
>
> > > > so this will result in:
>
> > > > <cfset stprops_pollingvote.answer1 = "1"> ect etc
>
> > > > this is however not working, as this is a part of a structure, do i
> > > > need it to create otherwise?
>
> > > > Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"farcry-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/farcry-dev?hl=en
-~----------~----~----~----~------~----~------~--~---