Amortization Tables Mortgage Calculator Excel

Amortization Tables Mortgage Calculator

Calculate your mortgage payments and view amortization tables for any loan

Amortization Table

Payment Number Payment ($) Principal ($) Interest ($) Balance ($)
function calculateMortgage() { const loanAmount = parseFloat(document.getElementById(‘loanAmount’).value); const interestRate = parseFloat(document.getElementById(‘interestRate’).value) / 100 / 12; const loanTerm = parseInt(document.getElementById(‘loanTerm’).value) * 12; if (isNaN(loanAmount) || isNaN(interestRate) || isNaN(loanTerm) || loanAmount <= 0 || interestRate <= 0 || loanTerm <= 0) { alert("Please enter valid positive values for all fields."); return; } const monthlyPayment = (loanAmount * interestRate) / (1 – Math.pow(1 + interestRate, -loanTerm)); const totalAmountPaid = monthlyPayment * loanTerm; const totalInterest = totalAmountPaid – loanAmount; document.getElementById('monthlyPayment').value = monthlyPayment.toFixed(2); document.getElementById('totalInterest').value = totalInterest.toFixed(2); document.getElementById('totalAmountPaid').value = totalAmountPaid.toFixed(2); generateAmortizationTable(loanAmount, interestRate, loanTerm, monthlyPayment); } function resetCalculator() { document.getElementById('mortgage-calculator-form').reset(); document.getElementById('monthlyPayment').value = ''; document.getElementById('totalInterest').value = ''; document.getElementById('totalAmountPaid').value = ''; document.getElementById('amortizationTableContent').innerHTML = ''; } function generateAmortizationTable(loanAmount, interestRate, loanTerm, monthlyPayment) { let balance = loanAmount; const amortizationTable = document.getElementById('amortizationTableContent'); amortizationTable.innerHTML = ''; // Clear existing table content for (let i = 1; i <= loanTerm; i++) { const interestPayment = balance * interestRate; const principalPayment = monthlyPayment – interestPayment; balance -= principalPayment; const row = amortizationTable.insertRow(); row.insertCell(0).innerText = i; row.insertCell(1).innerText = monthlyPayment.toFixed(2); row.insertCell(2).innerText = principalPayment.toFixed(2); row.insertCell(3).innerText = interestPayment.toFixed(2); row.insertCell(4).innerText = Math.max(balance, 0).toFixed(2); // Prevent negative balance } }

Leave a Reply

Your email address will not be published. Required fields are marked *