
<tr>
    <td><input type="number" id="srno" name="srno" class="form-control" style="width: 50px;"> </td>
    <td><input type="text"   value="{{ $data->item ?? '' }}" class="form-control"> </td>
    <td><input type="number" class="purity_input form-control" name="Purity"  > </td>
    <td><input type="number"  name="weight"   value="{{ $data->weight ?? '' }}" class="form-control"> </td>
    <td><input type="number"   name="kwdamount"  value="{{ $data->kwdamount ?? '' }}" class="form-control"> </td>
</tr>
<script>

$(document).ready(function () {
   $('input[name="weighttotal"]').val(calcSum());
       $('input[name="weight"]').change(function () { 
         $('input[name="weighttotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="weight"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});



$(document).ready(function () {
   $('input[name="kwdamounttotal"]').val(calcSum());
       $('input[name="kwdamount"]').change(function () { 
         $('input[name="kwdamounttotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="kwdamount"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});

function numberRows() {
      $('input[name ="srno"]').each(function(i) {
            $(this).val(i + 1);
      });
		}
numberRows();


</script>