ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old September 3rd, 2004, 10:07 AM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
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?

Reply With Quote
  #2  
Old September 3rd, 2004, 10:27 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
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

Reply With Quote
  #3  
Old September 3rd, 2004, 10:35 AM
JackSNVC JackSNVC is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 72 JackSNVC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 29 m 6 sec
Reputation Power: 5
Smile yep

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

Reply With Quote
  #4  
Old September 3rd, 2004, 11:25 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
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.).

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > checkboxes damnit


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway