I have a number of fields to which I have added plus and minus buttons for the users to be able to increment the value.
These fields act as a 'quantity' field which has another input field above it with the price.
There is also another field which calculates the total of all the products selected and multiplies it by their quantity.
The problem I am having is that although the value in the input field is updating, it is not affecting the 'total' field. If however I manually type the input in with the keyboard, it works fine.
The code is as follows:
$('<span class="add" uk-icon="plus"></span>').insertAfter('.product-cotainer .product-quantity input');
$('<span class="sub" uk-icon="minus"></span>').insertBefore('.product-cotainer .product-quantity input');
//Add functinoality to + button
$('.add').click(function () {
if ($(this).prev().val() < 10) {
$(this).prev().val(parseInt(+$(this).prev().val() + 1));
}
});
//Add functinoality to - button
$('.sub').click(function () {
if ($(this).next().val() > 0) {
if ($(this).next().val() > 0)
$(this).next().val(+$(this).next().val() - 1);
}
});