|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Dynamic Variable
hi All.Torrent Girl 07/03/12 01:58 P I presume you have the dynamic part in another variable, in which case youRuss Michaels 07/03/12 02:09 P >I presume you have the dynamic part in another variable, in which case youTorrent Girl 07/03/12 02:55 P yes but presumably you are chagning that value, if not then you haveRuss Michaels 07/03/12 04:24 P >>I presume you have the dynamic part in another variable, in which case youTorrent Girl 09/12/12 08:44 A > the arrays are set into session:Leigh 07/03/12 03:51 P > the arrays are set into session:Leigh 07/03/12 04:03 P hi All. I have an application that creates an array based on a few variables. The application enters the contents of the array into a DB by looping over the array. My issue is that I need the array name in the loop to be dynamic based on another var I have set. EX: <cfset moduleGroup = "1A"> Here is how it goes: The arrays are set into session: <cfset session.ceuAppModules1A = [] /> <cfloop query="course1Apply" startrow="1" endrow="6"> <cfset arrayAppend( session.ceuAppModules1A, "#INTMODULEID#" ) /> </cfloop> The 1A part of the array name is what can change. It can be 1B, 4A, etc. What I would like to do is when I enter the contents of the array into the DB, I'd like the name of the array loop to be dynamic: Here is my loop: <cfloop array="#session.ceuAppModules1A#" index="i"> I want the "1A" part of the array name to be dynamic but I have spent too much time trying to come up with the correct syntax. Any suggestions? I presume you have the dynamic part in another variable, in which case you could do this. <cfloop array="#evaluate("session.ceuAppModules#othervariable#")#" index="i"> ----- Excess quoted text cut - see Original Post for more ----- ----- Excess quoted text cut - see Original Post for more ----- I do. I'll try that. Thank you. But wait. won't this give me a value of '1A'? yes but presumably you are chagning that value, if not then you have nothing to work with. You need to be generating the dynamic name you plan to use somehow. ----- Excess quoted text cut - see Original Post for more ----- >>I presume you have the dynamic part in another variable, in which case you > >I do. I'll try that. Thank you. > >But wait. won't this give me a value of '1A'? it's been a while since this post but thanks Russ that worked. > the arrays are set into session: > <cfset session.ceuAppModules1A = [] /> To access the element dynamically, use structure notation, ie: session["ceuAppModules"& theDynamicSuffixHere > the arrays are set into session: > <cfset session.ceuAppModules1A = [] /> > To access the element dynamically, use structure notation, ie: > session["ceuAppModules"& theDynamicSuffixHere Obviously there should be a closing bracket "]". The response was cut off for some reason .... ------------------------- Leigh some extra text here just to see where the message is cut off .
|
May 20, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||