How do you update checkboxes on a form in cold fusion?

I am using the following code to update other form elements :

<cfquery name="qry_content" datasource="A4265_gbci">
update tbl_emailsignup
set firstname = '#form.firstname#' ,
lastname = '#form.lastname#' ,
email = '#form.email#' ,
job = '#form.job#',
company = '#form.company#' ,
address1 = '#form.address1#' ,
address2 = '#form.address2#' ,
city = '#form.city#' ,
state = '#form.state#' ,
zip = '#form.zip#' ,
phone = '#form.phone#'
where id = #form.id#
</cfquery>

The value of a check box can be set using something like
<cfinput type="checkbox"
name="SelectedDepts"
value="4">
BUT this value will only be returned if the user checks the box, so either do an isDefined or use cfparam to default it to something.

One thing you should consider as well is changing your query to use cfqueryparam instead of puttine the actual value in quotes into the statement. This aids performance and also helps stop quotes in the data causing problems.
Nige

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.