How to use gform_calculation_result filter with trigger functions?

Hello, my programming skills are very basic. I have searched the forum for the answer to my problem and I have not been able to find a good solution.

It is about finding a way to use the filter “gform_calculation_result” in combination with other functions that allow to automatically activate the calculations:
“jQuery(document).ready(function(){}”
and
" jQuery(’#input’).on(‘change’,function (){}"

If for example I use:

    jQuery(document).ready(function(){
	jQuery('#input_1).on('change',function (){
	      
		result //calculation result
	});
	});
	
	gform.addFilter('gform_calculation_result', function( result, formulaField, formId, calcObj ) {
	  	if ( formId == '217' && formulaField.field_id == '3' ) {

			result = ;

		}
	return result;
	} );

The filter works but I can’t use the result of the calculations in the filter because it is contained in the previous function.

And if I use

gform.addFilter('gform_calculation_result', function( result, formulaField, formId, calcObj ) 
	jQuery(document).ready(function(){
	jQuery('#input_).on('change',function (){
	
		calculation
		
	});
	});
	
	return result;	
	});

Don´t work.
I have tried other combinations to place “Filter” with “jQuery (document) .ready (function () {” with “jQuery (’# input _). On (’ change ', function () {” but I have not found a way that everything works well to the time.

For example, In a theoretical case like this (in real case the calculations would be much more complex and only possible with JS), How could it be used the filter?

“gform.addFilter(‘gform_calculation_result’, function( result, formulaField, formId, calcObj )” to save the result in field id = 3

    jQuery(document).ready(function(){
    jQuery('#input_217_1,#input_217_2').on('change',function (){		

 a = jQuery('#input_217_1').val();  
 b = jQuery('#input_217_2').val();  		
	
	result = a*b;

  return result;
 });
});	

Thanks in advance

© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.