ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old October 9th, 2004, 11:49 AM
mikemac mikemac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Greenville NC
Posts: 70 mikemac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 15 m 24 sec
Reputation Power: 4
Question Nested loop problem...HELP!!!!

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

Reply With Quote
  #2  
Old October 9th, 2004, 07:52 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
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

Reply With Quote
  #3  
Old October 9th, 2004, 07:53 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
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">

Reply With Quote
  #4  
Old October 9th, 2004, 08:47 PM
mikemac mikemac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Greenville NC
Posts: 70 mikemac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 15 m 24 sec
Reputation Power: 4
Thumbs up you are very perceptive!!!!!!!!

Quote:
Originally Posted by kiteless
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">


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

Reply With Quote
  #5  
Old October 9th, 2004, 09:10 PM
mikemac mikemac is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Greenville NC
Posts: 70 mikemac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 15 m 24 sec
Reputation Power: 4
Thumbs down Another bit of insight please

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???

Reply With Quote
  #6  
Old October 10th, 2004, 03:55 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,626 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 6 m 34 sec
Reputation Power: 53
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!!!">

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Nested loop problem...HELP!!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway