Trigger Calculations

Hi there,
I probably should know this by now, buuuut I have a hidden field that is feeding data to a Calculating Product. However, it is not trigger when the Hidden Field is changed. It does trigger when a user changes a field. SO… How can I tell the Calculation to update when the hidden field changes?


Where does your hidden field get its value from - maybe there’s an issue there? Have you checked that it’s actually updated?

1 Like

Good points, but yes the field is updating just fine.

The hidden field is tied to a JavaScript that is finding the length of an array and populating that length into the the hidden field. I am fairly sure the script is not doing anything to interfere with the calculating field, but it might be firing after the calculation script.

I’m just hoping there is a hook to tell calculations to run again. Otherwise I’ll need to do all the calculations through JavaScript.

1 Like

The script which is setting the input value should trigger the change event at the same time e.g.

jQuery( '#input_id_here' ).val( 'something' ).change();


Thanks for the thought but that’s not quite what I need. change() doesn’t initiate a change, but it listens for one.

There is (has to be) a GF javascript that fires calculations, and that’s what I was wondering about. It’s probably somewhere but I’m going to have to workaround it for now.

The jQuery API docs indicate it can trigger and listen. As you aren’t passing in a callback it will trigger the change event. Gravity Forms uses it in this way to trigger the change event when calculations are complete so conditional logic based on calculation fields is evaluated.

Well, I’ll play with that, but in the meantime I just wrote the code to change the product input and span:

			$(document).on('change', 'input', function(){
			var backpacking_test = $( '#input_7_2 > option:contains("Overnight Backpacking")' )[0].selected;
				var bp_hikers = $('input#input_7_10').val();
				if( bp_hikers > 1 ){
					var bp_days = $('input#input_7_65').val();
					var bp_extra = ( bp_hikers - 1 ) * bp_days * 100;
					console.log( bp_extra );
					bp_extra = parseFloat(Math.round(bp_extra * 100) / 100).toFixed(2);
					$( 'input#ginput_base_price_7_64' ).val( '$'+bp_extra );
					$( 'span#input_7_64' ).text( '$'+bp_extra );
1 Like
© 2008 - 2019. Gravity Forms is a project by Rocketgenius Inc.