Print - Calculating loan repayment rate - JavaScriptBank.com

You wanna to make a website for online loan? Or you have a loan of someone, now you need to calculate the mount of money must pay? If so, let's use this JavaScript code, it helps you calculate money must accurately and fast, you need to enter the information requested: loan amount, interest rate, length of loan (months), ... jsB@nk hope this code will help you reduce stress with loan debt, interest...

CSS
`<style type="text/css"><!--#calculator {  width: 410px;}#calculator label { display: block; margin-top: 0.8em;}#result strong { display: block;}--></style>`

JavaScript
`<script type="text/javascript"><!--// Created by Morley Computing - http://www.morley-computing.co.uk/var currency = '\$';//// Do the calculation. //function calculatePayment(form) {// P = Lr(1+r/1200)^n/[1200{(1+r/1200)^n - 1}]// P is monthly payment// L is loan amount// r is interest rate// n is number of monthsL = 1 * form.amount.value;r = 1 * form.interest.value;n = 1 * form.months.value;// String to capture output...var str = '';// Do calculations and build output...for (i=0; i < form.type.length; i++) {if (form.type[i].checked) {val = form.type[i].valueif (val == 'both' || val =='compound')  {P = doCompoundCalculation(L, r, n);str = str +"<strong><em>Compound Rate</em></strong><br>" + "<strong>Total amount repayable:</strong> " + formatMoney(n*P) +"<strong>Monthly repayment:</strong> " + formatMoney(P) + "<br><br>";}if (val == 'both' || val =='flat')  {P = doFlatRateCalculation(L, r, n);str += "<strong><em>Flat Rate</em></strong><br>" + "<strong>Total amount repayable:</strong> " + formatMoney(n*P) +"<strong>Monthly repayment:</strong> " + formatMoney(P);}}}document.getElementById('result').innerHTML = str;}//// Calculate payment using a compounded rate. //function doCompoundCalculation(L, r, n) {// L is loan amount// r is APR// n is number of monthsP = L * r * Math.pow(1+r/1200,n) / (1200 * (Math.pow(1+r/1200,n) - 1));return P;}//// Calculate payment using a flat rate (no compounding). //function doFlatRateCalculation(L, r, n) {// L is loan amount// r is flat rate// n is number of monthsT =  (1 + (n * r/1200)) * L;P = T/n;return P;}//// Only allow digits and decimal point.//function setNumericOnly(object) {value = object.value;object.value = value.replace(/[^d.]/g, "");}//// Format money to 2dp and add commas...// Based on script by: Cyanide_7// See: http://javascript.internet.com/forms/currency-format.html// function formatMoney(num) {num = num.toString().replace(/\$|,/g,'');if(isNaN(num)) num = "0";sign = (num == (num = Math.abs(num)));num = Math.floor(num*100+0.50000000001);dec = num%100;num = Math.floor(num/100).toString();if(dec<10) dec = "0" + dec;for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) {num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3));}return currency + (((sign)?'':'-') + num + '.' + dec);}//--></script>`

HTML
`<div id="calculator"><form id="calculatorForm"><fieldset><legend>Loan Details</legend><label for="amount">Loan Amount:</label><input class="numeric" id="amount" name="amount" value="10000" maxlength="10" size="6" onkeyup="setNumericOnly(this);" type="text"><label for="interest">Interest Rate:</label><input class="numeric" id="interest" name="interest" value="7.8" maxlength="6" size="6" onkeyup="setNumericOnly(this);" type="text"><label for="months">Length of Loan (Months):</label><input class="numeric" id="months" name="months" value="12" maxlength="6" size="6" onkeyup="setNumericOnly(this);" type="text"><label for="type">Interest Type:</label><input name="type" id="type" value="compound" checked="true" type="radio">Compound (APR)<input name="type" id="type" value="flat" type="radio">Flat Rate<input name="type" id="type" value="both" type="radio">Calculate Both<label for="action">&nbsp;</label><input id="action" name="action" value="Calculate" maxlength="10" onclick="calculatePayment(document.forms.calculatorForm); return false;" type="submit"></fieldset></form><!-- Calculation results will appear here --><div id="result"></div></div>`