I would suggest giving a common class to your fields so that:
<input type="text" class="quantity" onblur="calculateTotal();" />
Then you can define the following function using jQuery:
function calculateTotal() {
var total = 0;
$(".quantity").each(function() {
if (!isNaN(this.value) && this.value.length != 0) {
total += parseFloat(this.value);
}
});
$("#total_quantity").val(total);
}
onblur , . , calculateTotal().
, $("input[id^='Quantity[']"), Felix . , : Quantity[