<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script> function totalPrice($val){ let amt = 0; let arrlength = 1; let arr = document.getElementsByName('owner_shares'); for(let index = 0; index < arr.length; index++){ let price = arr[index].value; amt = +(amt)+ +(price); arrlength = arr.length; } document.getElementById('profitpk').value = amt; } function get_profit(){ let fixed_cost = $('#fixed_cost').val(); let urgent_cost = $('#urgent_cost').val(); let target_sales = $('#target_sales').val(); let add = Number(fixed_cost)+ Number(urgent_cost); let profit = Number(target_sales)-Number(add); let amt = 0; let arrlength = 1; let arr = document.getElementsByName('owner_shares'); for(let index = 0; index < arr.length; index++){ let price = arr[index].value; amt = +(amt)+ +(price); arrlength = arr.length; } let total_profit = profit/arrlength; // alert(total_profit); document.getElementById('profits').value = total_profit; // document.getElementsByClass('owner_shares').value(total_profit); $('.owner_shares').val(total_profit); } function urgent_cost_change(){ } function target_sales_change(){ } $(document).ready(function(){ $(document).on('click', '.addbtn', function(){ $('.duplicateForm .duplicate:last-child').clone().appendTo('.duplicateForm'); }); }); $(document).ready(function(){ $(document).on('click', '.dltbtn', function(){ if($('.duplicateForm .duplicate').length > 1){ $(this).parents('.duplicate').remove(); } }); myFunction(); }); </script>