I apologize -- one line is off.

In the VALUES part of your SQL, I inadvertently put #ThisID# in twice.  The second one 
should be changed back to #Place#.  Sorry!

-Andy 

> -----Original Message-----
> From: Andrew Tyrone [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 02, 2001 5:16 PM
> To: CF-Talk
> Subject: RE: i need List Help (and a thanks)
> 
> 
> Jay,
> 
> Try out the following:
> 
> <!--- Outer loop.  Each iteration is one of the six select boxes, 
> from 1 to 6 --->
> <cfloop from="1" to="6" index="CurrentSelect">
> 
>       <cfset RodeoID = Form.RodeoID>
>       <cfset EventID = Form.EventID>
>       <cfset Place = CurrentSelect>
>       <cfset TimeTaken = Evaluate("form.Place#CurrentSelect#TimeTaken")>
>       <cfset Points = Evaluate("form.Place#CurrentSelect#Points")>
>       <cfset AdjPoints = Evaluate("form.Place#CurrentSelect#AdjPoints")>
>       <cfset MoneyEarned = 
> Evaluate("form.Place#CurrentSelect#MoneyEarned")>
>       <cfset NotAllAround = 
> Evaluate("form.Place#CurrentSelect#NotAllAround")>
>       
>       <cfset ContestantIDs = Evaluate('FORM.Place' & 
> CurrentSelect & 'ContestantID')>
>       
>       <!--- Inner loop.  You can loop over a list of only 1 item. 
>  You don't have to have 2 separate identical inserts depending on 
> the length of each select box variable --->
>       <cfloop list="#ContestantIDs#" index="ThisID">
>       
>               <cfquery name="PutResults" 
> datasource="#datasource#" username="#username#" 
> password="#password#" dbtype="ODBC">
>               INSERT INTO ResultsManager (RodeoID, EventID, 
> ContestantID, Place, TimeTaken, Points, AdjPoints, MoneyEarned, 
> NotAllAround)
>               VALUES (
>               '#RodeoID#',
>               '#EventID#',
>               '#ThisID#',
>               #ThisID#,
>               #TimeTaken#,
>               #Points#,
>               #AdjPoints#,
>               #MoneyEarned#,
>               #NotAllAround#)
>               </cfquery>
>       <!--- Close Inner loop --->
>       </cfloop>
> 
> <!--- Close outer loop --->
> </cfloop>
> 
> 
> I couldn't run this as it pertains to your app, but it should 
> work.  Noticed I shortened it quite a bit.  I put in some 
> comments to show you why.  The problem had to do with your nested 
> lists.  When you sit back and think about it, you'll realize you 
> have an outer and inner list.  The outer list will always be 6 (I 
> assume you are validation this part on your own), so that we 
> know.  Within each Select list that is sent to your action page, 
> there could be 1 or more values.  You can loop over a list of 1 
> value.  Doing it in this way, you eliminate the need to have 
> separate SQL code for inserting 1 or many Contestants into the database.
> 
> I hope it works for you!
> 
> -Andy 
> 
> > -----Original Message-----
> > From: Jay Patton [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, March 02, 2001 10:01 AM
> > To: CF-Talk
> > Subject: i need List Help (and a thanks)
> > 
> > 
> > I submitted this again because im not sure that it went through 
> > the first time.
> > 
> > I'm back with another question ( imagine that :)
> > First i would like to say thanks to everyone that has helped me 
> > so far a lot of things have worked great!
> > 
> > what i have is a form that has 6 selection box's (all multiple 
> > select box's) which list's all of the contestans in a circuit.
> > if i select just one person for each place 1st through 6th 
> > everything is great. however when i need to select two for 
> > a place (example: tie in first or something like that) im trying 
> > to get the insert page to put each contestant on there own
> > row in the DB. rather than put a comma between the ContestantID's 
> > This is what i have now but for some reason it still adds the
> > comma's and doesnt put them on there own row.
> > 
> > <!-- PART OF THE FORM.-->
> > 
> > <!-- The form feild that has the name "LoopList" looks like this -->
> > 
> > <input type="hidden" name="LoopList" value="1,2,3,4,5,6">
> > 
> > 
> > <!-- Then i have a form with 6 selection menues that look like this -->
> > <!-- I want to have the abilaty to select more than one of these 
> > on all 6 selection menus and insert a differant row for each 
> selected -->
> > 
> > <select name="Place1ContestantID" size="2" multiple>
> >         <option value="">Select Contestant <cfoutput 
> query="Contestants">
> >         <option value="#ContestantID#">#LastName#, #FirstName# 
> > (#Age#)</cfoutput>
> > </select>
> > 
> > 
> > <!--THE INPUT PAGE -->
> > 
> > 
> > <!-- Adds Records To The DB. -->
> > 
> > <cfloop index="LoopList" list="#form.LoopList#">
> > 
> > <cfset RodeoID = #Form.RodeoID#>
> > <cfset EventID = #Form.EventID#>
> > <cfset Place = #LoopList#>
> > <cfset TimeTaken = #Evaluate("form.Place#LoopList#TimeTaken")#>
> > <cfset Points = #Evaluate("form.Place#LoopList#Points")#>
> > <cfset AdjPoints = #Evaluate("form.Place#LoopList#AdjPoints")#>
> > <cfset MoneyEarned = #Evaluate("form.Place#LoopList#MoneyEarned")#>
> > <cfset NotAllAround = #Evaluate("form.Place#LoopList#NotAllAround")#>
> > 
> > <cfset ListCheck = #ListLen("form.Place#LoopList#ContestantID")#>
> > 
> > <!-- If Form only has 1 entry for each place 1st through 6th 
> (NO TIES) -->
> > <!-- Adds a row for each Contestant Selected in form -->
> > 
> > <cfif ListCheck EQ 1>
> > 
> > <cfset ContestantID = #Evaluate("form.Place#LoopList#ContestantID")#>
> > 
> > <cfquery name="PutResults" datasource="#datasource#" 
> > username="#username#" password="#password#" dbtype="ODBC">
> > INSERT INTO ResultsManager (RodeoID, EventID, ContestantID, 
> > Place, TimeTaken, Points, AdjPoints, MoneyEarned, NotAllAround)
> > VALUES (
> > '#RodeoID#',
> > '#EventID#',
> > '#ContestantID#',
> > #Place#,
> > #TimeTaken#,
> > #Points#,
> > #AdjPoints#,
> > #MoneyEarned#,
> > #NotAllAround#)
> > </cfquery>
> > 
> > <cfelse>
> > 
> > <!-- If Form has more than on entry for any of the places 1st 
> > through 6th ex: a tie in first OR second ect... -->
> > <!-- Should enter a new row for each ContestantID that is 
> > selected in the multiple select box's -->
> > <!-- rather than adding a comma ',' between their ID Number in 
> > the same row -->
> > 
> > <cfloop index="LoopContestantID" 
> > list="#form.Place#LoopList#ContestantID#">
> > 
> > <cfset ContestantID = #LoopContestantID#>
> > 
> > <cfquery name="PutResults" datasource="#datasource#" 
> > username="#username#" password="#password#" dbtype="ODBC">
> > INSERT INTO ResultsManager (RodeoID, EventID, ContestantID, 
> > Place, TimeTaken, Points, AdjPoints, MoneyEarned, NotAllAround)
> > VALUES (
> > '#RodeoID#',
> > '#EventID#',
> > '#ContestantID#',
> > #Place#,
> > #TimeTaken#,
> > #Points#,
> > #AdjPoints#,
> > #MoneyEarned#,
> > #NotAllAround#)
> > </cfquery>
> > 
> > </cfloop>
> > </cfif>
> > </cfloop> 
> > 
> > Thanks,
> > 
> > Jay Patton
> > Web Design / Application Design
> > Web Pro USA
> > 406.549.3337 ext. 203
> > 1.888.5WEBPRO
> > www.webpro-usa.com
> > [EMAIL PROTECTED]
> > 
> > 
> > **********************************
> > "Trust Everyone....
> > But Always Cut The Cards."
> > **********************************
> > 
> > 
> > 
> >
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to