Helpful Information
 
 
Category: ColdFusion
FORM.FieldNames Checkboxes

Hey

Im trying to retreive the value of a checkbox in my script i.e. checked/unchecked.
Problem is if i uncheck the box on the form and submit it, the checkbox is not picked up in the form variables.
Any Ideas?


<td><input type="checkbox" name="CONTACTED" value="#getClientTransactions.paymentAttemptID#" <cfif getClientTransactions.Contacted eq 1>checked="true"</cfif> ></td>

Im trying to retreive the value of a checkbox in my script i.e. checked/unchecked.
Problem is if i uncheck the box on the form and submit it, the checkbox is not picked up in the form variables.

thats how checkboxes work...if they are unchecked they are not sent as part of the form post...if u want the value irrespective of whether the checkbox is checked or not then use hidden fields

thats how checkboxes work...then use hidden fields
A simplier approach is to use the CFPARAM tag:

<cfparam name="FORM.Contacted" default="unchecked">

You can also check to see if is defined in the page that parses it.

e.g.



<cfif IsDefined(FORM.checkbox)>
...
<cfelse>
...
</cfif>










privacy (GDPR)