I'm trying to sum up my checked checkboxes and inputs with values in them. Currently I'm getting both separately (and it functions how I want it to) like this:
$(document).ready(function() {
$('.box').change(function(){
var totalbox = 0;
$('.box:checked').each(function(){
totalbox+= +($(this).attr("rel"));
});
$('#totalbox').val(totalbox.toFixed(2));
});
});
$(document).on("recalc", ".vendor_accounts", function () {
var totalinput = 0;
$(this).find(".payment").each(function () {
totalinput += +$(this).val();
});
$("#totalinput").val(totalinput.toFixed(2));
});
$(".vendor_accounts").trigger("recalc");
The above functions produce the right results separately. I just need to combine the values of those results and display them as one var inside an id.
Per the below answer, this is what did the trick:
function updateGrandTotalDisplayed(val){
var input1 = parseFloat($('#checkTotal').val());
var input2 = parseFloat($('#inputTotal').val());
var total = input1 + input2;
$('#totalPrice').val(total.toFixed(2));
};