|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Dynamicaly assigning variable names.
It's been a while since I last worked with CF... so this is probably easy, but the logic is currently failing me.
I am trying to create a set of session vars dynamicaly from a loop... but I completely forgot how to assign the session var names dynamicaly. Code:
<cfquery name="ClassE_QuestionsN" datasource="#application.DNSmatrix#"> SELECT CEQ_ID FROM CLASS_EVENT_QUESTIONS </cfquery> <cfoutput>Number of inputs: #ClassE_QuestionsN.recordcount#</cfoutput> <cfoutput query="ClassE_QuestionsN"> <cfset Qname = "form.question_" & #CEQ_ID#> <cfset Q_value = Evaluate(Qname)> <br>Question ID: #CEQ_ID# --> Value = #Q_value# and session name will be: <cfset S_Qname = "question_" & #CEQ_ID#> #S_Qname# <cfset session.#S_Qname# = "#Q_value#"> </cfoutput> <cfdump label="Sess" var="#session#"> This line returns an error: <cfset session.#S_Qname# = "#Q_value#"> What I'm trying to get is something like: <cfset session.question_1 = "#Q_value#"> <cfset session.question_2 = "#Q_value#"> <cfset session.question_3 = "#Q_value#"> etc ...
__________________
Saintaw pending. |
|
#2
|
||||
|
||||
|
Duh!!!!!!!!!!!!!!!!
<cfset "session.#S_Qname#" = "#Q_value#"> I hate mondays... |
|
#3
|
|||
|
|||
|
Or this:
<cfset session[S_Qname] = Q_value />
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Dynamicaly assigning variable names. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|