Loan Summary:
Loan Amount: $0.00
Total Interest Paid: $0.00
Total Cost of Loan: $0.00
function calculateMortgage() {
// Get Input Values
var price = parseFloat(document.getElementById("mcHomePrice").value);
var downPayment = parseFloat(document.getElementById("mcDownPayment").value);
var rate = parseFloat(document.getElementById("mcInterestRate").value);
var years = parseFloat(document.getElementById("mcLoanTerm").value);
var annualTax = parseFloat(document.getElementById("mcPropertyTax").value);
var annualIns = parseFloat(document.getElementById("mcInsurance").value);
var monthlyHOA = parseFloat(document.getElementById("mcHOA").value);
// Validation
if (isNaN(price) || price < 0) price = 0;
if (isNaN(downPayment) || downPayment < 0) downPayment = 0;
if (isNaN(rate) || rate < 0) rate = 0;
if (isNaN(years) || years <= 0) years = 30;
if (isNaN(annualTax) || annualTax < 0) annualTax = 0;
if (isNaN(annualIns) || annualIns < 0) annualIns = 0;
if (isNaN(monthlyHOA) || monthlyHOA < 0) monthlyHOA = 0;
// Calculations
var principal = price – downPayment;
var monthlyTax = annualTax / 12;
var monthlyIns = annualIns / 12;
// Interest calculations
var monthlyRate = (rate / 100) / 12;
var numberOfPayments = years * 12;
var monthlyPI = 0;
if (rate === 0) {
monthlyPI = principal / numberOfPayments;
} else {
// Formula: M = P[r(1+r)^n/((1+r)^n)-1)]
monthlyPI = principal * ( (monthlyRate * Math.pow(1 + monthlyRate, numberOfPayments)) / (Math.pow(1 + monthlyRate, numberOfPayments) – 1) );
}
// Total Monthly Payment
var totalMonthly = monthlyPI + monthlyTax + monthlyIns + monthlyHOA;
// Total Loan Stats
var totalPaidOverLife = (monthlyPI * numberOfPayments);
var totalInterest = totalPaidOverLife – principal;
// Update UI
document.getElementById("resPI").innerHTML = "$" + monthlyPI.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resTax").innerHTML = "$" + monthlyTax.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resIns").innerHTML = "$" + monthlyIns.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resHOA").innerHTML = "$" + monthlyHOA.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resTotal").innerHTML = "$" + totalMonthly.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resLoanAmount").innerHTML = "$" + principal.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resTotalInterest").innerHTML = "$" + totalInterest.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resTotalCost").innerHTML = "$" + (totalPaidOverLife + downPayment).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
// Show results
document.getElementById("calc-results").style.display = "block";
}
Understanding Your Mortgage Payment (PITI)
When planning to purchase a home, looking at the listing price is just the tip of the iceberg. Smart homebuyers focus on the PITI—an acronym that stands for Principal, Interest, Taxes, and Insurance. This calculator provides a comprehensive breakdown of your true monthly costs, ensuring you aren't blindsided by hidden expenses.
Components of Your Monthly Payment
Principal: The portion of your payment that goes toward paying down the loan balance ($). In the early years of a mortgage, this amount is typically small compared to interest.
Interest: The cost of borrowing money. Your interest rate significantly impacts your monthly payment. Even a 1% difference can change your buying power by tens of thousands of dollars.
Taxes: Property taxes are assessed by your local government. They are often bundled into your monthly mortgage payment and held in an escrow account.
Insurance: Lenders require homeowners insurance to protect the asset. Like taxes, this is usually divided into 12 monthly payments and added to your mortgage bill.
HOA Fees: If you are buying a condo or a home in a managed community, Homeowner Association fees are paid separately but must be factored into your monthly budget.
How Interest Rates Affect Affordability
Interest rates fluctuate based on the economy and your credit score. A lower interest rate means a lower monthly payment and less money paid over the life of the loan. For example, on a $300,000 loan, the difference between a 6% and 7% interest rate is roughly $200 per month and over $70,000 in total interest over 30 years. Use the tool above to experiment with different rates and see how they impact your bottom line.