mercredi 19 août 2020

how to implement total discount value and total filed row using jQuery

I'm trying to displays total DCS amount (discount amount ), and total filed row value.

<script type="text/javascript">
    
  $('tbody').delegate('.quantity,.price,.gst,.dcs', 'keyup', function() {
      var tr = $(this).parent().parent();
      var quantity = tr.find('.quantity').val();
      var price = tr.find('.price').val();
      var gst = tr.find('.gst').val();
      var dcs = tr.find('.dcs').val();
      var totalamountgst = (quantity * price * gst) / 100;
      var totalamountdcs = (quantity * price * dcs) / 100;
      var totalamounts = (quantity * price + totalamountgst);
      var totalamount = (totalamounts - totalamountdcs);


      tr.find('.totalamount').val(totalamount);
      total();

      
    });

    function total() {
      var total = 0;
      $('.totalamount').each(function(i, e) {
        var totalamount = $(this).val() - 0;
        total += totalamount;
      });
      $('.total').val(total + ".00");
    } 
</script>

view code

<!-- below input shows total dcs amount -->
<td > <input type="text" class=" input-lg form-control totaldcs"  name=""  placeholder="TOTAL DCS" 

value="">

<!-- below input shows total filed row -->
<td > <input type="text" class="text-danger  input-lg form-control totalitems"  name="" 

placeholder="TOTAL ITEMS" value="" >



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire