|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
I am having one heck of a time with CFLOOP to assign SESSION variables dynamically.
On the loop in question below here is my mindset. What this loop is doing is assigning a single SESSION variable to each form field input provided by the user. When this loop executes I get the following error….. <!--- Invalid CFML construct found on line 16 at column 24. ColdFusion was looking at the following text:#The CFML compiler was processing: * a cfset tag beginning on line 16, column 2. * a cfset tag beginning on line 16, column 2. - <!--- Here is the code- <CFSET M=1> <CFSET k=1> <body> <CFLOOP from="1" to="#SESSION.NumberOfQuest#" index="i" step="1"> <CFOUTPUT> <cfset SESSION.Question#M#=FORM.question#M#> <cfset SESSION.CorrectAnswer#M#=FORM.correctAwn#M#> </CFOUTPUT> <!---inner question loop, loops #SESSION.NumOfAwnz# times---> <CFLOOP from="1" to="#SESSION.NumOfAwnz#" index="j" step="1"> <CFIF "#k#" GT "#SESSION.NumOfAwnz#"> </CFIF> <CFOUTPUT> <cfset SESSION.Answer#a#=FORM.answer#i#.#k#><CFOUTPUT> </CFOUTPUT> <cfset k=k+1></TD></CFOUTPUT> </CFLOOP> </CFLOOP> <CFFORM action="dataInsert.cfm" method="post"> <TR><TD><input type="submit" value="finished"></TD></TR> </CFFORM> Here is the goal of my forms. Form1.Create a form to accept user input (DONE) Form2.Create a form based on user input from Form1(DONE) Form3. Assign user input from Form2 to session variables(PROBLEMS!!!) Form4. Input each session variable from Form3 into database(NEXT) ------------------------------------------- I have also tried to assign it like this: <cfset SESSION.Question#M#=evaluate("FORM.Question#M#")> Any ideas???? ------------------------- Confucius say: All who help Newkirk will have good luck all day |
|
#2
|
||||
|
||||
|
In your CFif, you have double quotes around your values, get rid of those.
|
|
#3
|
|||
|
|||
|
Quote:
Thanks for the heads up but it is still a dud!!!! |
|
#4
|
|||
|
|||
|
Try something like this for your session variable assignment
<cfset structinsert( session, 'Question' & M, form['question' & m])> Hope it helps |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Dynamically assigning SESSION vars to form input |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|