
<tr>
    <td><input type="number" id="srno" name="srno" class="form-control" style="width: 50px;"> </td>
    <td><input type="text"  name="item[]" style="width: 100px;" value="{{ $data->item ?? '' }}" class="form-control"> </td>
    <td><input type="text"  name="qty[]"  value= "1" class="form-control" > </td>
    <td><input type="text"  name="grosswtgms[]"  value="{{ $data->grosswtgms ?? '' }}" class="form-control"></td>
    <td><input type="text" class="purity_input form-control" name="Purity[]" style="width: 80px;" > </td>
    <td><input type="text"  name="netgoldwtgms[]"   value="{{ $data->netgoldwtgms ?? '' }}" class="form-control"> </td>
    <td><input type="text"  name="diamondwtcts[]"  value="{{ $data->diamondwtcts ?? '' }}" class="form-control"> </td>
    <td><input type="text"  name="diamondcolour[]" style="width: 70px;" value="{{ $data->diamondcolour ?? '' }}" class="form-control"> </td>
    <td><input type="text"  name="diamondclarity[]" style="width: 70px;" value="{{ $data->diamondclarity ?? '' }}" class="form-control"></td>
    <td><input type="text"  name="colorstonewtcts[]"  value="{{ $data->colorstonewtcts ?? '' }}" class="form-control"> </td>
    <td><input type="text"   name="totalamount[]"  value="{{ $data->totalamount ?? '' }}" class="form-control"> </td>
    <td><input type="hidden" id="stockid" name="stockid[]" value="{{ $data->id ?? '' }}" > </td>
    <td><input type="hidden" id="saletype" name="saletype" value="Retail" > </td>
</tr>
<script>
$(document).ready(function () {
   $('input[name="qtytotal"]').val(calcSum());
       $('input[name="qty[]"]').change(function () { 
         $('input[name="qtytotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="qty[]"]').each(function() {
                tamount += parseFloat(($(this).val() ? $(this).val() : 0));
            });
  return tamount;
}
});



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


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

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


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


$(document).ready(function () {
   $('input[name="totalamounttotal"]').val(calcSum());
       $('input[name="totalamount[]"]').change(function () { 
         $('input[name="totalamounttotal"]').val(calcSum());
       });
       function calcSum() {
            var tamount = 0;
            $('input[name="totalamount[]"]').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>