I need to add a js function into a gravity forms field. I want to take a result from an id=4 field, and add this number as input for a js function, then run the function:
var defaultRate = 1.7;
var halfRate = 1.65;
if (*field id=3* >= *field id=4* /2 ) {
return halfRate;
} else {
return defaultRate;
},
and get the result as an output for my field. How do I refence them? Where do I paste the code? html field or custom js in settings?
I have seen this to use into custom js
<script>
gform.addFilter( 'gform_calculation_formula', function( formula, formulaField, formId, calcObj ) {
if ( formId == '8' && formulaField.field_id == '13' ) {
formula += '+5';
}
return formula;
} );
</script>
This is possible with Gravity Forms Advanced Calculations.
if ( F3 >= F4 ):
1.65
else:
1.7
endif;
The F3 and F4 refer to field IDs 3 and 4 respectively. If you find it clarifies the formula further, you could include the full or partial merge tag:
{:3} and {My Field:3}
{:4} and {My Other Field:4}