That's because you are assigning individual value to the field, not sum. Haven't tested it, but something like this should work:
Code:
<script>
function updateTotal()
{
var total = 0;
$('#dynamic-table tr').each(function() {
if (!this.rowIndex) return; // skip first row
var customerId = this.cells[4].innerHTML;
total += customerId;
}
$("#grand_total").val(total);
});
Out of curiosity, why are you not doing that on PHP side?