Hello,
This has almost certainly been asked before... so here we go
again:
I have a form that displays a set of items each with its own
checkbox. The number of choices will vary from day to day. The
user selects any number of the items displayed and these choices
are to be entered into a database.
The items come from the database so result from a query e.g.
<CFQUERY NAME="Items">
SELECT Item_Name, Item_ID
FROM Items
WHERE Active=1
</CFQUERY>
then I do something like this to create a set of checkboxes - I don't
know
how many checkboxes there are so I have to create the names
dynamically:
<TABLE>
<CFSET Count = 0>
<CFOUTPUT>
<CFLOOP QUERY="Items">
<CFSET Count = #Count# +1>
<TR>
<TD><B>#Item_Name#</B></TD>
<TD><INPUT TYPE="CHECKBOX" name="Choice_#Count#"
value="#Item_ID#"> </TD>
</TR>
</CFLOOP>
</CFOUTPUT>
</TABLE>
so the next template receives a set of FORM.Choice_1,
FORM.Choice_2 and so on which contain the Item_ID values that I
need to insert into the database.
This where I am stumped - how do I step through those vales in
order to insert them? OR perhaps there is a BETTER WAY.
I guess I can't do this:
<LOOP INDEX="Count" FROM="1" TO="6">
<CFQUERY ... >
INSERT INTO Choices(Items)
Values('Choice_#Count#')
<CFQUERY>
</LOOP>
I could write the Choice_N values to an array Choices[N] then loop over
that but there must be a better way
Graham
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.