There's a couple of ways. Using CFPARAM is one. <cfparam name="Form.checkboxone" default="false">
Then, checked or unchecked, your action page will have a Form.checkboxone to work with. Another is to put logic inside your CFQUERY: <cfquery name="whatever" datasource="#DSN#"> INSERT INTO MYTABLE ( NAME, EMAIL, SPAMISOKAY ) VALUES ( '#FORM.NAME#', '#FORM.EMAIL#', <cfif IsDefined("Form.checkboxone")> 'Yes' <cfelse> 'No' </cfif> ) </cfquery> If you want to insert a NULL if the checkbox isn't checked, you can use the NULL attribute in CFQUERYPARAM. If NULL="Yes" then the information in VALUE= is ignored. <cfquery name="whatever" datasource="#DSN#"> INSERT INTO MYTABLE ( NAME, EMAIL, SPAMISOKAY ) VALUES ( <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#FORM.NAME#">, <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#FORM.EMAIL#">, <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#Form.checkboxone#" null="#YesNoFormat(NOT IsDefined('Form.checkboxone'))#"> ) </cfquery> > -----Original Message----- > From: Rick Faircloth [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 27, 2002 12:06 PM > To: CF-Talk > Subject: Best way to handle Checkboxes with Insert Query? > > > Hi, all. > > So I've abandoned CFINSERT in favor of CFQUERY Insert Into... > And am now using <cfqueryparam> to handle the values of the > formfields... > The problem is now checkboxes... > > When using CFINSERT, it didn't matter that a Checkbox was > unchecked and > therefore the formfield didn't exist. With the CFQUERY > Insert approach, > if a checkbox formfield is unchecked, the formfield is unrecognized. > If I use #ParameterExists(Form.Checkfield)# to check for the > formfield's > existence, > and it doesn't exist, and the <cfqueryparam> line which > establishes that > value > for the Insert doesn't get processed, the number of > formfields vs values > doesn't match. > > I've read on this list that it's recommended to use > #IsDefined()# in place > of #ParameterExists()#, > but doesn't IsDefined assume the existence of the variable, > and therefore > doesn't check > for the existence as does ParameterExists? CFPARAM? And why has > ParameterExists become deprecated > as a function anyway? > > So...with that in mind, what's the best way to handle an > Insert Query where > checkboxes > may or may not be checked on a form? > > Thanks, > > Rick > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm