Problem with checkboxes is that they only exist and show a value if they
have been checked.

For instance, you might have
<input type="checkbox" name="var" value="foo">

If its checked when the form is submitted, you will have form.var and the
value 'foo' to play with but if its not, then you get nothing so any code
that references form.var will break as it doesn't exist.

To get round it, declare the variables that are checkboxes in the page that
processes the form:
<cfparam name="form.var" default="">

hth, Doug

-----Original Message-----
From: Candace Cottrell [mailto:[EMAIL PROTECTED]]
Sent: 25 September 2002 16:40
To: CF-Talk
Subject: Re: Properly handling checkboxes


Does the ISdefined("form.checkbox") function not work for what you were
trying to do?

Can we see the code?

(Hey from a fellow Daytonian)



Candace K. Cottrell, Web Developer
The Children's Medical Center
One Children's Plaza
Dayton, OH 45404
937-641-4293
http://www.childrensdayton.org


[EMAIL PROTECTED]

>>> [EMAIL PROTECTED] 9/25/2002 11:30:40 AM >>>
I've got an HTML form that consists of mostly checkboxes.  Initially,
when I tested submitting the form, it was giving me problems for the
checkboxes that were NOT checked.  So I figured, OK, I need to figure
out some way to get the current value of the checkbox, then go ahead and
set it to checked, and then I'll be able to submit the form.  So I wrote
a little JavaScript function that loops through all of the items in the
form, if it's a checkbox, it checks whether or not it is checked, and
sets it's value, then it sets it to checked, and then it submits the
form.  All well and good, and actually does what I need it to do, IF the
user ends up being satisfied with the options that they checked.  I'd
like to go ahead have the action template for the form also be a
confirmation page, which will allow the user to review the options that
they've checked, and then submit their options to our database.  My
problem now though, is that if a user realizes that they've
inadvertently c!
hecked a box that they didn't mean to, or didn't check a box that they
needed to, I can put a link on that page so that they can go back to the
form and correct their options, but when you just go back (using
something like javascript: history.go(-1) or something like that), now
ALL of the checkboxes are checked.  Is there a better way (I'm sure
there must be, I just don't know what it is) to handle the submission of
forms with checkboxes, so that if a user has to go back to the form and
make changes, that it will set the form back to what they had originally
selected?  Any thoughts or ideas would be greatly appreciated.

::YEX::
<)))><

/*
|| Robert D. Yexley
|| Oracle Programmer/Analyst
|| Northrop Grumman IT
|| Contractor - Wright Research Site MIS
|| Det-1 AFRL/WSI Bldg. 45 Rm. 062
|| (937) 255-1984
|| [EMAIL PROTECTED]
|| <)))><
*/

 <<Robert D. Yexley (E-mail).vcf>>



______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to