Question

First see that post:

Get value with JQuery in gravity form

i'm trying this code but... nothing happend. Step by step i did:

  1. Fresh WP installation.
  2. Install Plugin Gravity Forms
  3. Create Form1 (Id of form = 1)
  4. Create Form2 (Id of form = 1)
  5. Add 5 number fields to Form2 (ids of fields are: 1,2,3,4,5)
  6. Add HTML field
  7. Put this code on HTML field:

    <script>
    gform.addFilter( 'gform_calculation_result', function(result, formulaField, formId, calcObj ){    
        if ( formulaField.field_id == "2" ) {
            var field_five = jQuery('#input_2_5').val();
            result = field_five * 12;
        }
        return result;
    });
    </script>
    
  8. Save changes to Form2.

  9. Clicked to preview of Form2

When writing the value 10 in the field (field ID = 5), the value of the field (field ID = 2), should appear with the value 120.

But nothing happens when I show the form and complete the fields.

What am I doing wrong?

Was it helpful?

Solution

The function gform_calculation_result is deprecated but the addFilter version isn't as it was only introduced in Gravity Forms 1.8

Did you update the script to work with your form, for example, is the id of your calculation field 2, if not you will need to change the formulaField.field_id == "2" part of the script. In that script you will also need to update #input_2_5 to match the id of the input you are retrieving the value for, that input id is targeting field 5 on form 2. You can confirm your field id by using the browser's document inspector to view the HTML for the field.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top