validate two checkbox variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CF FAN
    New Member
    • Mar 2008
    • 50

    validate two checkbox variables

    I want to validate this two checkbox variables on an action page and also an update page


    [CODE=cfm]<cfinput type="checkbox" name="gender"ch ecked> </label></td> <td>Female</td> <td><label> <cfinput type="checkbox" name="gender"> </label></td><cfinput type="checkbox" name="gender"ch ecked>
    </label></td>
    <td>Female</td>
    <td><label>
    <cfinput type="checkbox" name="gender">
    </label></td>
    [/CODE]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.
    Last edited by acoder; Jun 5 '08, 12:14 PM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You need to give values to your checkboxes. Shouldn't you be using radio buttons here, or can someone be of both genders? :p

    In your Coldfusion code, check that form.gender (if using POST) is defined, or use cfparam. If checked, it will be passed in url.gender or form.gender depending on whether you use the GET or POST method.

    Please use code tags when posting code.

    Comment

    • CF FAN
      New Member
      • Mar 2008
      • 50

      #3
      Oh it's working THANKS

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Glad it's working.

        Comment

        • wiredwizard
          New Member
          • Jul 2008
          • 3

          #5
          You may want to grab a copy of qforms works great and is very handy. I added it to my customtags folder and use on all my sites. Just google for qforms

          Comment

          Working...