Hi there,
I’m using a couple of number fields where I have added a PLUS and MINUS button to the right for a better user experience.
These fields are used to calculate a price later on in the field. This all works, however when a user presses + or - instead of manually typing a new number the calculation doesnt trigger. It does successfully confirm the entry after submitting it.
Is there a way to trigger the calculations every time the button is pressed?
I’m using the following jQuery to add the buttons:
$(function() {
$(".plusmin .ginput_container_number").append('<div class="dec plusminbutton">-</div><div class="inc plusminbutton">+</div>');
});
setTimeout(
function() {
$(".plusminbutton").on("click", function() {
var $button = $(this);
var oldValue = $button.parent().find("input").val();
if ($button.text() == "+") {
var newVal = parseFloat(oldValue) + 1;
} else {
// Don't allow decrementing below zero
if (oldValue > 0) {
var newVal = parseFloat(oldValue) - 1;
} else {
newVal = 0;
}
}
$button.parent().find("input").val(newVal);
});
}, 100);
I’ve tried using this: https://docs.gravityforms.com/gform_post_calculation_events/ - but I don’t understand how to apply that to the correct form/field-ID('s).
Thanks in advance.
Best,
Dave