Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting looped session variables 1

Status
Not open for further replies.

demiancurran

Programmer
Sep 20, 2006
19
CA
I need to set a session variable in a loop. Here is what the variable should produce once looped...

Code:
<cfset session.store[1].a1 = 18>
<cfset session.store[1].a2 = 18>
<cfset session.store[1].a3 = 18>

In the loop the 1 at the end of the variable needs to be looped, so I need to know how to set the variable. Here is what I have but when dumping the session it is not changing...

Code:
<cfloop index="x" from="1" to="3">
<cfset "#evaluate("session.store[1].a"&x)#" = 18>
</cfloop>

Thanks for your helP!
 
from the shot-in-the-dark department...

<cfset Evaluate("session.store[1].a"&x) = 18>


r937.com | rudy.ca
 
That does not work, I get the following error...

Can not assign a value to a function.
Unable to assign a value to the function "Evaluate" on line 14, column 8

Any other ideas?
 
Or
Code:
<cfset session.store[1]["a#x#"] = 18>

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
yeah, I like to leave out the # anywhere I can, some like them. either way should work.




Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Yeah, it's essentially the exact same thing, just a matter of preference.

Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Awesome, thanks guys. Works great.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top