1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

enter add / subtract quantities in a display field

Discussion in 'Community' started by giusebos, Feb 12, 2019.

  1. giusebos

    giusebos Member

    Level: Community
    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
    Code (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
     
  2. startpoint

    startpoint Active Member

    Level: Community
    Replace "$" with "jQuery" in your code.
     
  3. giusebos

    giusebos Member

    Level: Community
    ok it works, but strangling goes from 1 to 2 and po to 4 and then to 7 and then to 11 ....
     
  4. giusebos

    giusebos Member

    Level: Community
    I forgot I set event on click
     
  5. giusebos

    giusebos Member

    Level: Community
    set event on load and it works !!!
     

Share This Page