|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
checkboxes damnit
I have 4 checkboxes that hold values of X and each goes to a different column in a database. If the user doesnt check one of the values I keep getting the error:
Element COSTCAT is undefined in FORM basically costcat is a checkbox and if it isnt checked it will give me this error. I tried using like a cfif #form.costcat# eq "" cfset costcat = "none" and in my insert i name the value #costcat#. It still gives me the same error though. I have like 8 text boxes on the form that the user doesnt have to check but I dont think I should be getting these errors...any way to get around this? |
|
#2
|
|||
|
|||
|
This isn't really a CF problem, it's a limitation of HTML forms. Unchecked check boxes are not sent in the form post, regardless of web server or app server.
What you really want to do is <cfif not structKeyExists( 'form', 'myCheckbox' )> ....they didn't check the box.... </cfif> or you could do <cfparam name="form.myCheckbox" default="none" /> at the top of the page, and then if the checkbox isn't there it will be created with a default of an "none".
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Kiteless...you my friend are living genius. Hah. I really appreciate it and now have a better understanding of cfparm. Shoot I have learned a lot of this stuff with your help i appreciate it.
Works fine ![]() |
|
#4
|
|||
|
|||
|
No problem. cfparam is very useful. And you don't have to use it to always set a default, if you do:
<cfparam name="form.myFormField" /> Then this will throw an error if that variable doesn't exist. Handy for when you're asserting that a variable must exist for the rest of the code to process. You can also assert that a variable is of a specific type (string, number, structure, query, etc.). |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > checkboxes damnit |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|