|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
I am making a form so teachers can create tests that are inserted into the database using CFMX as the front end. Here is my code below, any ideas on what I'm doing wrong?????
<!---create question and answer bank using multiple loops then populate test bank with results---> <!---outer loop iterates once per question ---> <!--- inner loop iterates #SESSION.NumOfAwnz# times per question---> <CFFORM name="questionGEN" action="questGEN.cfm"> <!---Outer question loop, loop #SESSION.NumberOfQuest# times---> <CFLOOP from="1" to="#SESSION.NumberOfQuest#" index="i"> Question (#i#) <cfinput name="question#i#" required="yes" message="please enter question in every empty field!!!" ><br /> <!---inner question loop, loops #SESSION.NumOfAwnz# times---> <CFLOOP from="1" to="#SESSION.NumOfAwnz#" index"j"> Qusetion #i#/Answer #j#<cfinput name="answer#j#" required="yes" message="please enter answer in every empty field!!!" ><br /> </CFLOOP> </CFLOOP> <input type="submit" value="finished"> </CFFORM> Last edited by mikemac : October 9th, 2004 at 11:49 AM. Reason: oooooops |
|
#2
|
|||
|
|||
|
The first thing you need to do is explain what the problem is please.
__________________
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 |
|
#3
|
|||
|
|||
|
Also I notice right off the bat that your syntax is wrong.
This: <CFLOOP from="1" to="#SESSION.NumOfAwnz#" index"j"> Must be this: <CFLOOP from="1" to="#SESSION.NumOfAwnz#" index="j"> |
|
#4
|
|||
|
|||
|
Quote:
You were Correct!!!! Its the little things. I looked over that line a million times and never picked up the missing "=" PS I see you live in Raliegh hopefully you are a Wolfpack fan as am I. And if you check the scoreboard the UNC Tarholes just beat us. My wife is a Tarhole fan and I'm getting a new one torn in me as we speak!!!!! Last edited by mikemac : October 9th, 2004 at 08:57 PM. Reason: saw the scoreboard |
|
#5
|
|||
|
|||
|
During my nested loop iteration I receive this error...
<!--- Duplicate CFForm element name "answer1" for tag CFInput. Each name within a CFForm must be unique. The error occurred on line 53. ---> Here is the loop in question... <CFLOOP from="1" to="#SESSION.NumberOfQuest#" index="i" step="1"> Question (#i#) <cfinput name="question#i#" required="yes" message="please enter question in every empty field!!!" ><br /> <!---inner question loop, loops #SESSION.NumOfAwnz# times---> <CFLOOP from="1" to="#SESSION.NumOfAwnz#" index="j" step="1"> Answer #j#<cfinput name="answer#j#" required="yes" message="please enter answer in every empty field!!!" ><br /> </CFLOOP> --------------------------------------------------------- from what i gather its telling me that the "answer#j#" is not incrementing upon its second iteration. Should it not automaticallly increment by one each pass thru??? |
|
#6
|
|||
|
|||
|
For each iteration of the outer loop, the inner loop is naming the form fields the same thing. This is the problem. Just make the form field use both indexes in the name and every one should be unique, something like this:
<cfinput name="answer#i##j#" required="yes" message="please enter answer in every empty field!!!"> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Nested loop problem...HELP!!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|