First see that post:
Get value with JQuery in gravity form
i'm trying this code but... nothing happend. Step by step i did:
- Fresh WP installation.
- Install Plugin Gravity Forms
- Create Form1 (Id of form = 1)
- Create Form2 (Id of form = 1)
- Add 5 number fields to Form2 (ids of fields are: 1,2,3,4,5)
- Add HTML field
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>Save changes to Form2.
- 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?
jQuery( "#input_1_5" ).click(function() {to fire my own function, which did the maths and set the other field's value. I imagine you could also usejQuery( "#input_1_5" ).change(function() {- Stevewhat_checked_21 = jQuery('input[name=input_21]:checked').val()to get the value using the iD of the element found from doing "View Source" on the form. Not sure what the equivalent would be for changed perhapswhat_checked_21 = jQuery('input[name=input_21]:changed').val()- Steve