jQuery - Update Product Value [RESOLVED]

Hey all,
So I am trying to populate this product field:

<li id="field_35_48" class="gfield exclude gfield_price gfield_price_35_48 gfield_product_35_48 gfield_calculation field_sublabel_below field_description_above gfield_visibility_visible" style="display: list-item;"><label class="gfield_label" for="input_35_48_1">Service Fee $</label><div class="gfield_description"><b>Script</b> - As we've talked about, we will now be applying a service fee in conjunction with your balance.  The total for this fee is...</div><div class="ginput_container ginput_container_product_calculation">
	<input autocomplete="new-password" type="hidden" name="input_48.1" value="Service Fee $" class="gform_hidden">
	<span class="ginput_product_price_label">Price:</span> <span class="ginput_product_price" id="input_35_48">$ 33.30</span>
	<input autocomplete="new-password" type="hidden" name="input_48.2" id="ginput_base_price_35_48" class="gform_hidden" value="$33.30">
	<input autocomplete="new-password" type="hidden" name="input_48.3" value="1" class="ginput_quantity_35_48 gform_hidden">

using a jQuery:

	if( total >= 0 ){
		$( '#ginput_base_price_35_48' ).attr( 'value', '$'+total );
		$( 'span#input_35_48' ).text( '$ ' + total );
		$( '#ginput_base_price_35_48' ).attr( 'value', 0 );
		$( 'span#input_35_48' ).text( '$ 0.00' );

And it seems to work, but then when I submit the form, the product and total are $0.00 in the entry. Any thoughts on why that could be?

You’re handling the JS side of things but you’ll also need to account for these dynamic price changes on the PHP side. I’d recommend this filter:

Thanks David! I’ll give that a go. I did make it work by using the jQuery to populate a hidden field, and then had the product field “calculate” the value for the hidden field. It’s like using duct tape a bailing twine!

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