• 1.
    <script>
  • 2.
    jQuery(document).ready(function( $ ) {
  • 3.
    // Prepends a checkbox to the field and hides the quantity box for fields with custom class .checkbox_qty
  • 4.
    // Add this code to an HTML Content form field in Gravity Forms
  • 5.
     
  • 6.
    $('.checkbox_qty').each(function() {
  • 7.
      var ck_name = 'ck_'+$(this).attr("id");
  • 8.
      var checkbox = '<input type="checkbox" value="Yes" class="add_option" id="'+ck_name+'" />';
  • 9.
      $(this).prepend(checkbox);
  • 10.
      $(this).find('.gfield_label').attr("for", ck_name);
  • 11.
      $(this).find('.ginput_quantity_label').css("display","none");
  • 12.
      $(this).find('.ginput_quantity').css("visibility","hidden");
  • 13.
    });
  • 14.
     
  • 15.
    $('.add_option').change(function(){
  • 16.
        var qty = this.checked ? '1' : '0';
  • 17.
        var field = $(this).parent().find('.ginput_quantity');
  • 18.
        field.val(qty);
  • 19.
     });
  • 20.
     
  • 21.
    });
  • 22.
    </script>
<script> jQuery(document).ready(function( $ ) { // Prepends a checkbox to the field and hides the quantity box for fields with custom class .checkbox_qty // Add this code to an HTML Content form field in Gravity Forms $('.checkbox_qty').each(function() { var ck_name = 'ck_'+$(this).attr("id"); var checkbox = '<input type="checkbox" value="Yes" class="add_option" id="'+ck_name+'" />'; $(this).prepend(checkbox); $(this).find('.gfield_label').attr("for", ck_name); $(this).find('.ginput_quantity_label').css("display","none"); $(this).find('.ginput_quantity').css("visibility","hidden"); }); $('.add_option').change(function(){ var qty = this.checked ? '1' : '0'; var field = $(this).parent().find('.ginput_quantity'); field.val(qty); }); }); </script>

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter