Hi Melissa,

Checkboxes can be a little bit tricky.  First off, I'd recommend NOT using
CFINSERT or CFUPDATE.  Especially with checkboxes, it can be
counterproductive...at best you loose control.  As you probably already
know, when a checkbox is turned off, it does not send ANYTHING to the action
page.  It just won't be defined at all.  So, take advantage of CFPARAM tag.
It will allow you to make the default value 0 for any checkbox field that is
"not defined" because it wasn't checked.

In other words, if you have a checkbox called "my_checkbox" on the form,
than you'll want to have a cfparam on the action page that looks something
like:

<CFPARAM name="form.my_checkbox" default="0">

Then in your INSERT or update query, you can always reference
#form.my_checkbox# and it will be 1 if the box was checked or 0 if its not
defined.

If you have multiple checkboxes, just use multiple CFPARAMs.

Another method would be to do an "isdefined()" function for each checkbox.
In your insert query, you'd need a CFIF statement for each checkbox that
would look something like:

<CFIF isdefined("form.my_checkbox")>
1,
<CFELSE>
0,
</CFIF>

Finally, if you really want to use CFINSERT or CFUPDATE, I think you need to
put a hidden field by the name of each checkbox in your form with a value of
0.  This way, if the checkbox is not checked the form will still send a
value of 0 for that field (and if it is checked, the value will be 1,0 which
CFINSERT/CFUPDATE seem to be able to deal with)

HTH,

Eron



-----Original Message-----
From: Melissa Fraher [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 19, 2000 6:55 PM
To: [EMAIL PROTECTED]
Subject: [CF-Talk] checkboxes -- processing multiple boxes


How would you process multiple check boxes that are submitted on a
form?  I can't seem to get it working.
----------------------------------------------------------------------------
--
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.

------------------------------------------------------------------------------
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.

Reply via email to