Click here to Skip to main content
14,735,318 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
here using count addrow id rows are generated dynamically this below function only gives sum of first input field which is static and second which is dynamic in third field its giving sum of 1st and 3rd field help me with this we are new to JS?

What I have tried:

function calTotal(sum) {
	var w=0;


	var sum = Number(document.getElementById("total").value) + Number(document.getElementById("total"+w).value);
	// var sum1 = sum + Number(document.getElementById("total"+w).value);
	w++;
	
		document.getElementById("sub").value = sum.toFixed(2);

}
Posted
Comments
Richard MacCutchan 7-Nov-20 5:37am
   
Your function calculates the sum of the fields at id total and total0. That is all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900