•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 332,687 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,425 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser:
Views: 762 | Replies: 2
![]() |
•
•
Join Date: Feb 2008
Posts: 16
Reputation:
Rep Power: 1
Solved Threads: 0
Hello friends,
I want to validate this two checkbox variables on an action page and also an update page
by default I checked one of them, how can I check if it is checked and what is the best way to store this in the database and have the right checkbox checked when you want to update the form.
I want to validate this two checkbox variables on an action page and also an update page
coldfusion Syntax (Toggle Plain Text)
<cfinput type="checkbox" name="gender"checked> </label></td> <td>Female</td> <td><label> <cfinput type="checkbox" name="gender"> </label></td>
Last edited by peter_budo : Mar 30th, 2008 at 5:37 am. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Feb 2008
Posts: 32
Reputation:
Rep Power: 1
Solved Threads: 3
You need to specify a value for each one.
For instance:
When you process the page, the Form.Gender variable will contain either "Male" or "Female" depending on which is checked (or "Male,Female" if both are checked, which can be used as a list incidentally). Make sure to use
<cfif IsDefined("Form.Gender")> before checking for the values, otherwise it will throw an error if none of the checkboxes are checked, unless you've created it with <cfparam>.
For instance:
ColdFusion Syntax (Toggle Plain Text)
<cfinput type="checkbox" name="gender" value="Male" checked> </label></td> <td>Female</td> <td><label> <cfinput type="checkbox" name="gender" value="Female"> </label></td>
When you process the page, the Form.Gender variable will contain either "Male" or "Female" depending on which is checked (or "Male,Female" if both are checked, which can be used as a list incidentally). Make sure to use
<cfif IsDefined("Form.Gender")> before checking for the values, otherwise it will throw an error if none of the checkboxes are checked, unless you've created it with <cfparam>.
ColdFusion Syntax (Toggle Plain Text)
<cfparam name="Form.Gender" default=""> <cfif Form.Gender EQ "Male"> <!--- Do something ---> <cfelseif Form.Gender EQ "Female"> <!--- Do something else ---> </cfif>
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ColdFusion Marketplace
Other Threads in the ColdFusion Forum
- Previous Thread: <cfquery> Undefined
- Next Thread: mdf as datasource


Linear Mode