you cant do this directly from php try using jquery/javacript
Procedure to do it from jquery
In a way that when ever value of the input field is changed call a function which will re calculate the sum of all the fields again
Say you have a table in html like
|id|Name |Price|
----------------------
|1 |Some name |10 |
|2 |Some name |20 |
|3 |Some name |30 |
|4 |Some name |40 |
----------------------
| | |100 |
and and input field some where in a form.
Id
of that input field = "priceInputField"
and Class
of each column containing price = "priceValue"
and Id of the column containing the total is "totalPrice"
so your jquery function would look like
$("#priceInputField").on("change",function(){
//Some code to add the new row in the table
var updatedPrice = 0;
$(".priceValue").each(function(){
updatedPrice = updatedPrice + $(this).text;
})
$("#totalPrice").text("updatedPrice");
});