Monday, April 3, 2017

Make sum total in javascript

I am not very familiar with javascript so i think that I need some help from you guys. I am making a personal project with Laravel and it is like a POS. I have done everything ok until now, my confusion is that after I have added product in my "cart". I can change the qty by clicking in image of product, I need to do this even if I change the qty manually and I need to change subtotal in real time by the new qty i gave it. Thanks a lot in advance.

<table class="table table-xs">
<thead>
<tr>
    <th>#</th>
    <th>Product</th>
    <th>Price</th>
    <th>QTY</th>
    <th>Total</th>
</tr>
</thead>
<tbody id="products-table">
@if(Session::get('products'))
    @foreach(Session::get('products') as $product)
        <tr  id="product-row">
            <td class="click-to-remove-product" data-element-id =><a href="javascript:;"><i class="icon-cross"></i></a></td>
            <td></td>
            <td></td>
            <td><input type="number" class="click-to-add-product form-control" value="" id="quantity-product" min="0" step="1"></td>

            <td id="subtotal-product"></td>
        </tr>
    @endforeach
@endif

</tbody>

enter image description here



via User154584

Advertisement