Hydrowizard wrote:
> Why does this happen though and how does coldfusion
evaluate it? TIA
I'm not sure what your difficulty is, but but my
interpretation is that
you are confused by ColdFusion evaluating the variable
'key1var' to the
value 'key1' and then using that value as the key of the
structure.
This is expected, accepted, designed and desired behavior.
Otherwise
how would one dynamically call structure elements using
variables if CF
did not evaluate those variables.
Maybe this basic example would make the point a little clear.
<cfset aStruct = structNew()>
<cfset aStruct.key1 = "Foo">
<cfset aStruct.key2 = "Bar">
<cfset aStruct.key3 = "George">
<cfoutput>
<cfloop list="key1,key2,key3" index="j">
#aStruct
#
</cfloop>
<hr/>
<cfloop from="1" to="3" index="j">
#aStruct['key' & j]#
</cfloop>
</cfoutput>
This technique is very powerful when combined with the
knowledge that
form data is a structure.