Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2005
    Location
    Ireland
    Posts
    122
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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?

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

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by tom123 View Post
    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
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Las Vegas, NV - USA
    Posts
    104
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by shyam View Post
    thats how checkboxes work...then use hidden fields
    A simplier approach is to use the CFPARAM tag:

    <cfparam name="FORM.Contacted" default="unchecked">
    Steven Sommers (blog)
    Shift4 Corporation -- www.shift4.com

    Creators of $$$ ON THE NET(tm) payment processing services.

  • #4
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can also check to see if is defined in the page that parses it.

    e.g.

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •