We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12028
    • 152 Posts
    Could it be a missing:
    [[!FormItRetriever]] 

    - before the FormIt call?

    Maybe this old thread can help:
    https://forums.modx.com/thread/72320/check-boxes-in-formit
      - A small step for mankind, so why not take two...

      Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!
      • 5904
      • 58 Posts
      Thanks for reply, Henrik. Added [[!FormItRetriever]] before the FormIt call. No change in result :/
        • 12028
        • 152 Posts
        This works for me:
        <input type="checkbox" id="subscribe" name="subscribe" value="Yes" [[!+fi.subscribe:FormItIsChecked=`Yes`]] />
          - A small step for mankind, so why not take two...

          Working with web production, graphic design/workflow, photo and education - but are trying to get a life in between!
          • 5904
          • 58 Posts
          Quote from: Henrik at Apr 02, 2015, 05:12 AM
          This works for me:
          <input type="checkbox" id="subscribe" name="subscribe" value="Yes" [[!+fi.subscribe:FormItIsChecked=`Yes`]] />

          Thanks, Henrik. Puzzling as it's not working here with this in contactForm chunk:

          ...
          <div class="row">
          	<div class="form-group short">
          		<div class="col-md-12">
          			<label>Your email address *</label>
          			<input type="text" id="email" name="email" class="col-md-12 form-control" maxlength="100" value="">
          			<label class="checkbox-inline small">
          				<input type="checkbox" id="subscribe" name="subscribe" value="Yes" [[!+fi.subscribe:FormItIsChecked=`Yes`]]>Receive our special offers by email
          			</label>
          		</div>
          	</div>
          </div>
          ...
          


          and simply this in contactFormTpl chunk:

          <p>Subscribe: #[[+subscribe]]#</p>


          Output: 'Subscribe: #Yes#' when checkbox checked and 'Subscribe: #Yes#' when checkbox unchecked.

          Any thoughts? Anyone? [ed. note: craigphiz last edited this post 11 years, 6 months ago.]
            • 5904
            • 58 Posts
            It's working!

            In the ajax script I changed the line that passes the checkbox value.

            "subscribe": $("#contactFormModal #subscribe").val(),


            changed to:

            "subscribe": $("#contactFormModal #subscribe:checked").val(),


            Hope this helps someone. Thanks all for your support!
              • 14877
              • 110 Posts
              I found your post when I was looking to see how to retrieve checkbox values. The coding looked wrong, so I experimented based on how FormIt works with radio buttons (i.e. Select tags).

              Here's the reference for Select: http://rtfm.modx.com/extras/revo/formit/formit.hooks/formit.hooks.email

              Here is what works (I've just copy-and-pasted my own code so I wouldn't make errors coding it for your situation). Just change this example appropriately.

              <input type="checkbox" id="banquet" name="banquet" value="Will not attend banquet" [[!+fi.banquet:FormItIsChecked=`Will not attend banquet`]] />
                __________________
                JRG