Auto Loan Payment Calculator with Amortization

Introduction | Demonstration Calculator | Source Code

How The Auto Loan Payment with Amortization Works

This calculator uses the same mathematical functions as our Simple Auto Loan Calculator, but iterates through each payment, calculating the interest and principal amounts for each payment as you pay off the loan.

Introduction | Demonstration Calculator | Source Code

Demonstration Calculator

Loan Amount:
Loan Term: months
APR Interest:

Payment:

Introduction | Demonstration Calculator | Source Code

Auto Loan Payment with Amortization Source Code

This calculator is licensed to you under Creative Commons Attribution 3.0. If you would like to use the source code on your site or create a derivative work from it, you must include the following HTML on the page where the calculator appears. We’re giving you this code for free with a legal license to use it. All you have to do is credit us in the manner we specify.

Required Credit HTML

INSTALLATION

Just cut and paste the Javascript code and HTML form below into your page. If you want to customize the appearance of the form, feel free. Just make sure the input name and form id/name values are not changed.


<script type="text/javascript">

var amortsub = false;

function calcLoan() {

var formvals = getFormVal();

var years = formvals[0];
var months = years;

var loan = formvals[2];
var apr = formvals[1];

var mpr = apr / 1200;
var nfactor = 0 - months;
var mofactor = Math.pow((1 + mpr), nfactor);
var bofactor = 1 - mofactor;
var tofactor = mpr / bofactor;

var payment = loan * tofactor;
var reducto = Math.round(payment*100)/100;

document.wcbubba.payment.value = "$"+reducto;

if (amortsub) showAm();

}

function showAm(){

amortsub = true;

formvals = getFormVal();

var years = formvals[0];
var months = years;

var loan = formvals[2];
var apr = formvals[1];

var mpr = apr / 1200;
var nfactor = 0 - months;
var mofactor = Math.pow((1 + mpr), nfactor);
var bofactor = 1 - mofactor;
var tofactor = mpr / bofactor;

var payment = loan * tofactor;
var reducto = Math.round(payment*100)/100;

document.wcbubba.payment.value = "$"+reducto;

// NOW WE CALCULATE THE AMORTIZATION

var intpaid = 0;
var princpaid = 0;
var factsout = "";
var inyear = 0;
var inmonth = 0;

document.getElementById('amortsub').innerHTML = '<b style="font-size:19px;">MONTHLY AMORTIZATION</b><br><br>';

for(var i=0;i<months;i++){
intpaid = Math.round((mpr * loan) *100)/100;
princpaid = Math.round((reducto - intpaid)*100)/100;
loan = Math.round((loan - princpaid)*100)/100;

inyear = parseInt(i/12);
inmonth = i - (inyear * 12);

factsout += '<b>Year ' + (inyear + 1) + ' Month ' + (inmonth +1) + ':</b><br>   Principal Paid: $' + princpaid + '<br>   Interest Paid: $' + intpaid + '<br>   Principal Remaining: $' + loan + '<br>';

}
document.getElementById('amortsub').innerHTML += factsout;

flush();

}

function getFormVal(){

var years = parseInt(document.wcbubba.term.value);
var loan = parseInt(document.wcbubba.loan.value);
var apr = parseFloat(document.wcbubba.apr.value);

if((years <= 0)||(isNaN(years))) years = 1;
if((apr <= 0)||(isNaN(apr))) apr = 1;
if((loan <= 0)||(isNaN(loan))) loan = 1;

var mike = new Array(years,apr,loan);

return mike;
}

</script>

<form id="wcbubba" name="wcbubba" action="javascript:void();">
Loan Amount: <input type=text name="loan" size=8><br>
Loan Term: <input type=text name="term" size=8> months<br>
APR Interest: <input type=text name="apr" size=8><br><ber>

<input type="submit" value="Calculate Payment" onClick="calcLoan();"> <b>Payment:</b> <input type=text name = "payment" size=9><br>
<input type="submit" value="Show Amortization" onClick="showAm();">
</form><br><br>

<div id="amortsub">

</div> 

Leave a Reply