PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Getting Hidden Fields to Populate with gform_pre_submission

  1. iSupportU
    Member

    Here's my function:

    add_action('gform_pre_submission_filter_2', 'combinefields');
    function combinefields($form) {
      $_POST['input_16'] = $_POST['input_11'];
      return $form;
    }

    I have not been able get to hidden field 16 populated from checkbox list 11 in form ID2. My main goal is to concatenate two fields into one, so we can send a single field of content to another Add-on to send to Salesforce. I'm stumped why this isn't working with one field. The hidden field has the box checked for "Allow field to be populated dynamically."

    Any suggestions?

    Posted 11 years ago on Wednesday May 1, 2013 | Permalink
  2. You could try using jQuery to replicate the value of one field into another. This forum entry describes that approach: http://www.gravityhelp.com/forums/topic/passing-values-on-multipage-form#post-179789

    Posted 11 years ago on Thursday May 2, 2013 | Permalink
  3. iSupportU
    Member

    I don't think that works either. Here's the form and the code I tried.

    <script type='text/javascript'>
      jQuery(document).ready(function($)  {
    	$("#input_2_12").blur(function()  {
          // sets the value of 12 for what was entered in 11
    	  $("#input_2_12").val($("#input_2_11").val());
    	});
      });
    </script>
    Posted 11 years ago on Thursday May 2, 2013 | Permalink
  4. I created a form with the same fields and got the following script to do what you needed:

    <script type='text/javascript'>
    jQuery(document).ready(function( $ ) {
    $('#input_2_11').change(function() {
    $('#input_2_12').val($(this).val());
    });
    });
    </script>

    The value will change once your cursor is no longer focused/inside of the input_2_11.

    Hope this accomplishes what you needed.

    Posted 11 years ago on Thursday May 2, 2013 | Permalink
  5. iSupportU
    Member

    Thanks Pierski, but I tried it and still wasn't able to get the hidden field populated, it ends up blank.

    I changed the inputs to two single-line visible fields to test, and I couldn't get that to work either. I also tried with two non-hidden fields on a different form, but no luck. No errors in the console.

    Any ideas to help narrow the issue down a bit?

    Posted 11 years ago on Friday May 3, 2013 | Permalink
  6. Can post a link to your form? I was able to get the solution I mentioned above to work on my own testing site. Maybe looking at the page itself will shed a little light on the issue.

    Posted 11 years ago on Friday May 3, 2013 | Permalink
  7. iSupportU
    Member

    I currently have this:

    <script type='text/javascript'>
    jQuery(document).ready(function( $ ) {
    $('#input_1_4').change(function() {
    $('#input_1_7').val($(this).val());
    });
    });
    </script>

    Set up targeting this form for testing, hoping it would be more obvious than testing with the form with hidden fields.

    Let me know if there's anything I can try adjusting. Appreciate your time thus far!

    Posted 11 years ago on Friday May 3, 2013 | Permalink
  8. Try moving the script lower on the page. You are calling it before you load any version of jQuery which the script itself needs to be able run. Maybe try right before the closing </head> tag.

    Posted 11 years ago on Saturday May 4, 2013 | Permalink
  9. iSupportU
    Member

    Ah, could that be why the gform_pre_submission_filter wasn't working in the first place? I'll experiment, thanks for the eyeballs!

    Posted 11 years ago on Monday May 6, 2013 | Permalink