I have a form with school classes on it. There could be any number of classes on this form, each with 2 fields. Cost of books and cost of tuition.
I have a 3rd field called grand total which I want to update as they are typing in the costs in the other fields.
This is how I have it set up:
    $(document).on( "keyup", ".cost", function(){
        theCost = parseFloat($(this).val(), 2) || 0;
        grandTotal(theCost);
    });
    // Calculate the total
    function grandTotal(theCost){
        totalCost = (totalCost + theCost);
        console.log(totalCost);
    }
Since this runs on every keyup, if i type in 44 it just adds 4+4.
Is there a better way to do this in order to get the value of the field and not each number typed?
 
     
     
     
     
    