enter add / subtract quantities in a display field

giusebos

Member
Hi guys,
I would like to be help.
I added this code in a display field:
HTML:
<div class="input-group">
    <span class="input-group-btn">
      <button type="button" class="quantity-left-minus btn btn-danger btn-number"  data-type="minus" data-field="">
        <span class="icon-minus"></span>
      </button>
    </span>
    <input type="text" id="quantity" name="quantity" class="input-mini form-control input-number" value="1" min="1" max="100">
      <span class="input-group-btn">
        <button type="button" class="quantity-right-plus btn btn-success btn-number" data-type="plus" data-field="">
            <span class="icon-new"></span>
        </button>
      </span>
</div>

on this page you can see the code in action
https://bootsnipp.com/snippets/e3q3a

I would like your help to adapt this script to allow the code to work
JavaScript:
$(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);

         
            // Increment
       
    });

     $('.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
            if(quantity>0){
            $('#quantity').val(quantity - 1);
            }
    });
   
});
I tried to insert the code in the javascript section, but the increase or decrease of the number does not work
 
Back
Top