From ea4b383e66cb258ff09dbff44bbc18476a674925 Mon Sep 17 00:00:00 2001 From: Marek Baczynski Date: Sun, 25 Nov 2018 00:01:11 +0200 Subject: [PATCH] fixed the numeric picker --- order_site/static/picker.js | 53 ++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/order_site/static/picker.js b/order_site/static/picker.js index 337e9ef..c17de50 100644 --- a/order_site/static/picker.js +++ b/order_site/static/picker.js @@ -1,36 +1,39 @@ + $(document).ready(function(){ var quantitiy=0; - $('.quantity-right-plus').click(function(e){ - - // Stop acting like a button - e.preventDefault(); - // Get the field name - var quantity = parseInt($('#quantity').val()); - - // If is not undefined - - $('#quantity').val(quantity + 1); - + $('.quantity-right-plus').click(function(e){ + + // Stop acting like a button + e.preventDefault(); + // Get the field name + var quantity = parseInt( $(this).parent().siblings('input').val() ) ; + + // If is not undefined - // Increment - - }); + // $('#quantity').val(quantity + 1); + + $(this).parent().siblings('input').val(quantity + 1) - $('.quantity-left-minus').click(function(e){ - // Stop acting like a button - e.preventDefault(); - // Get the field name - var quantity = parseInt($('#quantity').val()); - // If is not undefined + // Increment + + }); + + $('.quantity-left-minus').click(function(e){ + // Stop acting like a button + e.preventDefault(); + // Get the field name + var quantity = parseInt( $(this).parent().siblings('input').val() ) ; - // Increment - if(quantity>0){ - $('#quantity').val(quantity - 1); - } - }); + // If is not undefined + // Increment + if(quantity>0){ + $(this).parent().siblings('input').val(quantity - 1); + } + }); + }); function submitOrder(){