For one thing, you have too many pound signs.

<cfset mylist = listappend(mylist, #FORM[ 'Q#Results.QuestionID#' ]#)>

Should be

<cfset mylist = listappend(mylist, FORM[ "Q#Results.QuestionID#" ])>

Where is "Results.QuestionID" coming from? If you're using this code
inside of a loop for a query result, you either need to put that value
in a local variable or explicitly name the row.

Results.QuestionID[CurrentRow]


 

-----Original Message-----
From: Joel Watson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 06, 2007 8:53 AM
To: CF-Talk
Subject: Re: Insert Looped Form Entry into Database

Thanks for the quick response!  This does work, but now I am running
into another problem.  While it submits the right number of entries to
my database (in this case, 7), it submits the same value for all (e.g.,
Havanna, Havanna, Havanna, Havanna, Havanna, Havanna, Havanna).  Here is
the code that I am using:

<cfif isDefined("FORM.Submit")>
<cfdump var="#form#">
<cfparam name="mylist" default="">
        <cfloop from="1" to="#Test.RecordCount#" index="i">
        <cfset mylist = listappend(mylist, #FORM[
'Q#Results.QuestionID#' ]#)>
        </cfloop>
<cfquery datasource="Test">
UPDATE Users
        SET AnswerID =
  '#mylist#'
        WHERE Username = "existdissolve"
</cfquery>
</cfif> 


The loop gives me the correct number of entries, but does not separate
the values.  If I do a straight loop of the query "Results," it enters
all the values, but duplicates each value per the number of answer
options available.

Again, I really appreciate both your guy's help!

Joel


>Access the FORM struct using array notation:
>
>#FORM[ "Q#QuestionID#" ]# 
>
>This should work the way you expect it to.
>
>.....................
>Ben Nadel
>Certified Advanced ColdFusion MX7 Developer
>www.bennadel.com
> 
>Need ColdFusion Help?
>www.bennadel.com/ask-ben/
>
>-----Original Message-----
>From: Joel Watson [mailto:[EMAIL PROTECTED] 
>Sent: Tuesday, March 06, 2007 7:37 AM
>To: CF-Talk
>Subject: Insert Looped Form Entry into Database
>
>I have a cfform that is dynamically populated with test questions and
>answer choices from a database.  The answer choices are also
dynamically
>named based upon the id of the question, e.g., input
>name="Q#QuestionID#". I am currently able, upon submit, to pass the
>values of user-selected answers, producing this:
>
>struct
>FIELDNAMES    SUBMIT,Q1,Q2,Q3,Q4,Q5,Q6,Q7
>Q1    Mexico City
>Q2    Seattle
>Q3    London
>Q4    Istanbul
>Q5    True
>Q6    HEre is an essay question
>Q7    Here is an essay question
>SUBMIT    Submit Test
>
>My question is how do I capture the fieldnames and values (i.e., Q1 -
>Mexico City) so that I can place them in a database when the fieldnames
>are being dynamically created?  I initially tried an insert
>qualification like '#FORM.Q#QuestionID##', but obviously this does not
>work as CF complains about "Q" being undefined.  Any ideas would be
>greatly appreciated!
>
>Joel



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:271699
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to