Answers for "laravel , How can I increment and decrement value with unique id"

PHP
0

laravel , How can I increment and decrement value with unique id

function incrementValue(e)
    {
        // use the quantity field's DOM position relative to the button that was clicked
        const qty = e.target.parentNode.parentNode.querySelector("input.req.amnt");
        var value = parseInt(qty.value, 10);
        value = isNaN(value) ? 0 : value;
        value++;
        qty.value = value;
    }


    function decrementValue(e)
    {
        const qty = e.target.parentNode.parentNode.querySelector("input.req.amnt");
        var value = parseInt(qty.value, 10);
        value = isNaN(value) ? 0 : value;

        value--;
        if(value == -1) {
            value = 0;
        }
        qty.value = value;
    }
@forelse($allproduct as $key=>$data)
                            <tr>
                                <td data-label="@lang('Date')">
                                     <div class="quantity col-md-8" style="display:flex; ">
                                          <input type="text" value="" class="form-control req amnt display-inline" min="0">
                                       <div class="quantity-nav">
                                          <div class="quantity-button quantity-up qty" onclick="incrementValue(event)">+</div>
                                          <div class="quantity-button quantity-down qty" onclick="decrementValue(event)">-</div>
                                       </div>

                                    </div>
                                 </td>
                            </tr>
          @endforelse
Posted by: Guest on May-09-2022

Code answers related to "laravel , How can I increment and decrement value with unique id"

Browse Popular Code Answers by Language