treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[SOLVED]Adding two items not working

  • This is code from the editable invoice (http://css-tricks.com/html-invoice/) and instead of an Invoice I was trying to make a Quote form.

    So where it says "Amount Paid" and have "Total Labor" and I see in the code its subtracting 'Amount Paid' from the total, but when I remove the '-' sign and add the '+' sign it just adds both togeather like words for example' $875.00100.00,

    Current code that I think is doing the math, but I just want to add them.
    function update_balance() {
    var due = $("#total").html().replace("$","") - $("#paid").val().replace("$","");
    due = roundNumber(due,2);

    $('.due').html("$"+due);
    }


    Thanks for the help.
    Jake
  • I think parseFloat() is what you'll need there.

    var due = parseFloat($("#total").html().replace("$","")) - parseFloat($("#paid").val().replace("$",""));

    And in fact, you probably don't need the replace functions at all, parseFloat will ignore those.
  • That worked great!

    Thanks Chris.

    Can marked as solved.