Loan Calculator with Payment Schedule Generator
Enter Loan Data Here
Loan Amount:
$
Annual Percentage Rate (APR) %:
%
Repayment period in years:
Amount of payments per year:
Amount per payment:
$
Total paid over the life of the loan:
$
Total interest paid over the life of the loan:
$
(Please give the script time to work, especially if the loan is for a long time.)
Instructions:
1: Copy and paste the following script in the HEAD section of your page:
Select all...
<script language="javascript"> var amount, apr, n, payment, npy, tablebuilt=false; function calculate(){ var d=document.f; amount=d.amount.value; apr=d.apr.value; n=d.n.value; npy=d.npy.value; if( (amount!='') && (n!='') && (apr!='') && (npy!='') ){ tmp=Math.pow((1+(apr/100/npy)), (n*npy)); payment=(amount*tmp*(apr/100/npy))/(tmp-1); if((!isNaN(payment))&&(payment!=Number.POSITIVE_INFINITY)&&(payment!=Number.NEGATIVE_INFINITY)){ d.payment.value=round(payment); d.totpaid.value=round(payment*n*npy); d.intpaid.value=round((payment*n*npy)-amount); }else alert('Error:\nOne or more fields contain data\nwhich cannot be used in the\ncalculation.'); }else alert('Error:\nYou did not provide enough data.'); } function round(val){ tmp=Math.round(val*100)/100+''; if(tmp.indexOf('.')==-1)tmp+='.00'; else if(tmp.length-tmp.indexOf('.')==2)tmp+='0'; return tmp; } function resetall(){ var d=document.f; d.amount.value=''; d.apr.value=''; d.n.value=''; d.npy.value=12; d.payment.value=''; d.totpaid.value=''; d.intpaid.value=''; d.amount.focus(); } function buildtable(){ tablebuilt=true; txt='
Payment Schedule
'; txt+='
'; txt+='
'; txt+='
Payment
Number
Payment
Amount
Interest
Principle
Balance
'; amount=eval(amount); for(i=1;i<=n*npy;i++){ tbldata='
'; interest=amount*apr/npy/100; amount+=interest; principle=payment-interest; amount-=payment; txt+='
'+tbldata+i+':'+tbldata+round(payment)+''+tbldata+round(interest)+''+tbldata+round(principle)+''+tbldata+round(amount)+'
'; } txt+='
'; var psch=window.open('', 'viewsch' ,'top=0,left=0,toolbar=no,scrollbars=yes,resizable=yes,width=500,height=450,menubar=no,status=no'); psch.document.write(txt); } window.onload=function(){ document.f.amount.focus(); } </script>
2: Copy and paste the following HTML in the BODY section of your page:
Select all...
Enter Loan Data Here
Loan Amount:
$
Annual Percentage Rate (APR) %:
%
Repayment period in years:
Amount of payments per year:
Amount per payment:
$
Total paid over the life of the loan:
$
Total interest paid over the life of the loan:
$
(Please give the script time to work, especially if the loan is for a long time.)