jQuery().ready(function() { var value = 0; var total = 0; $('input.productquantity').keyup(function() { value = total = 0; if(!isNaN(parseInt($(this).val()))) { value = parseInt($(this).val()); $(this).parent().parent().children('.total').html('€ ' + (value * parseFloat($(this).next().val())).toFixed(2).replace('.', ',')); $('.overview .line').each(function() { if(!$(this).hasClass('head') && !$(this).hasClass('foot') && !$(this).hasClass('note')) { total += parseFloat($(this).children('.quantity').children('input[name="costs"]').val()) * parseInt($(this).children('.quantity').children('input.productquantity').val()); } }); $('.foot .total').html('€ ' + total.toFixed(2).replace('.', ',')); } }); });