value;
var loanTerm = document.getElementById("loanTerm").value;
var monthlyInterestRate = (interestRate / 100) / 12;
var numberOfPayments = loanTerm * 12;
var compoundedInterestRate = Math.pow((1 + monthlyInterestRate), numberOfPayments);
var interestQuotient = (monthlyInterestRate * compoundedInterestRate) / (compoundedInterestRate - 1);
var monthlyPayment = loanAmount * interestQuotient;
document.getElementById("monthlyPayment").value = monthlyPayment.toFixed(2);
document.getElementById("totalPayment").value = (monthlyPayment * numberOfPayments).toFixed(2);
document.getElementById("totalInterest").value = ((monthlyPayment * numberOfPayments) - loanAmount).toFixed(2);
}
php Copy code
Loan Calculator Generator
php Copy code