Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't CF process Check Boxes in FORM Tags that aren't checked! 2

Status
Not open for further replies.

happyb

Programmer
Oct 25, 2000
29
0
0
AU
HI,

I am trying to setup a form in CFML (using HTML Form Tags not CFFORM tags), to send a survey to an email address using CFMAIL. I am using check boxes in my form for a user to choose from a number of items. Now they can choose one or many or even none of these items... hence a radio button would not work.

But!.... when I send test this form and send it with out checks in some of the check boxes... it gives me an "Error Occurred While Processing Request" halt. It tells me that the specified form field cannot be found. The one that it cannot find is the one that I did not check.


Any ideas on how I can tell CF to process it? I was thinking of a CFSET tag... like True/False... but when I do check all the boxes... it process the form, but it just says that it is ON when I recieve the mail.

BTW I am referring to the check boxes in my CFMAIL body as #form.checkboxname#

Thanks
Happy :)
 
Without exception, checkboxes are not sent to the action page unless they are checked. I generally use the <cfparam> tag to set default values for checkboxes on the action page.

For example, on your form page you have:
<input type=&quot;checkbox&quot; name=&quot;Subscribe&quot; value=&quot;1&quot;>

At the top of your action page you would put:
<cfparam name=&quot;FORM.Subscribe&quot; default = 0>

I typically save checkbox type data as bit datatypes in SQL so the 0 & 1 are appropriate to me. That way I can immediately do an insert or update query and it'll work flawlessly. I'm sure you get the idea though.

Good luck!

Andrew
amayer@sonic.net
 
Perfect!

That fixed my problem! Thanks Andrew

Emma :)
 
I thought I was going crazy! I didn't know that unchecked values weren't passed and couldn't figure out why the unchecked ones weren't being updated in the database. This post was a lifesaver. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top