You cannot insert multiple values into one field unless you insert them as a comma delimite dlist, which is not a good idea. If you allow multiple checkboxes to be checked, then obviously you need to save multiple values, so you need a lookup table. I am presuming from your error below that StaffID is the checkboxes.
Staff_Lookup ------------ StaffID PracticeID And insert all the values into this table. <cfif listlen(form.staffID) GT 1> <cfloop list="#form.staffID#" index="id"> Insert into staff_lookup (staffID, practiceID) Values (#id#, #pa#) </cfloop> <cfelseif listlen(form.staffID EQ 1)> Insert into staff_lookup (staffID, practiceID) Values (#form.staffid#, #pa#) </cfif> -- Russ Michaels -----Original Message----- From: Pete [mailto:[EMAIL PROTECTED] Sent: 25 November 2006 08:44 To: CF-Talk Subject: RE: multiple selection drop down list I'm stumped on this one, just cant seem to think of a way to do it. I'm close but have been close for several hours. In summary I have 2 CF programs. Basically I am developing a website for a law firm. I have a CF program which displays a list of all staff. A user is then able to select a name displayed to modify. Basic details are OK. At the bottom of the page I have a number of checkboxes displayed which show areas of law which a person specializes in. If none are selected none will be checked. Basically a user can then make their selections and then press Save/Update. Currently when I click update I am getting an error message Error Executing Database Query. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Law,2) INSERT INTO tbl_staffpracareas(practiceid,staffid) VALUES(Planning L' at line 2 The error occurred in C:\Inetpub\wwwroot\yardy\controlpanel\staff\modify_process.cfm: line 58 56 : INSERT INTO tbl_staffpracareas(practiceid,staffid) 57 : VALUES(#pa#,#form.staffid#) 58 : </cfloop> 59 : </cfquery> 60 : __________________________________________________ Here is the code form the modify.cfm program. <table width="90%" align="left" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2"> </td> </tr> <cfoutput query="qGetPracticeAreas"> <tr> <td width="10%"><input<cfif (#staffid# IS NOT "")> checked</cfif> name="pracarealist" type="checkbox" value="#qGetPracticeAreas.practicearea#"></td> <td width="90%" class="OrderFormName">#qGetPracticeAreas.practicearea#</td> </tr> </cfoutput></table> THen in the modify_process.cfm program I have the following: <cftransaction> <cfquery datasource="#request.db_dsn#" username="#request.db_login#" password="#request.db_pwd#">Delete from tbl_staffpracareaswhere staffid = #form.staffid#</cfquery><cfparam name="form.pracarealist" default=""> <cfquery name="qInsertStaffPracAreas" datasource="#request.db_dsn#" username="#request.db_login#" password="#request.db_pwd#"><cfloop index="pa" list="#form.pracarealist#"> INSERT INTO tbl_staffpracareas(practiceid,staffid)VALUES(#pa#,#form.staffid#)</cfloop></ cfquery></cftransaction> -----Original Message----- From: Jim Wright [mailto:[EMAIL PROTECTED] Sent: Saturday, 25 November 2006 1:02 PM To: CF-Talk Subject: Re: multiple selection drop down list Pete wrote: > > <td width="10%"><input <cfif (#staffid# IS NOT > "")>checked="checked"</cfif> name="#qGetPracticeAreas.practicearea#" > type="checkbox" value='1'></td> > I would actually make the check boxes have the same name, and then just work off the list of values that is submitted... <input<cfif (#staffid# IS NOT "")> checked</cfif> name="pracarealist" type="checkbox" value="#qGetPracticeAreas.practicearea#"> > > I am thinking that I should probably put the code above within a > <cftransaction> tag. Then when I do the update I also would update the > tbl_staffpracareas table. > The cftransaction is a good idea. > > I am thinking that once a user presses the Update button that I need to > delete all records in the tbl_staffpracareas for a specific staffed and > then insert the correct records into the table. > That's the way I would do it...you may be able to do it in a single cfquery if you are using SQL Server...something like... <cfparam name="form.pracarealist" default=""> <cfquery...> SET NOCOUNT ON DELETE FROM tbl_staffpracareas WHERE staffid = #form.staffid# <cfloop index="pa" list="#form.pracarealist#"> INSERT INTO tbl_staffpracareas(practiceid,staffid) VALUES(#pa#,#form.staffid#) </cfloop> SET NOCOUNT OFF </cfquery> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:261648 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4