»
Tiếng AnhTiếng PhápTiếng Việt

In - Tính tiền trả góp 1 - JavaScriptBank.com

Phiên bản đầy đủ: jsB@nk » Tính toán » Tính tiền trả góp 1
URL: https://www.javascriptbank.com/amortization-calculator.html

Tính tiền trả góp 1 © JavaScriptBank.comHiệu ứng sẽ tạo một bảng dành cho việc mua trả góp của bạn cho một món nào đó.

Phiên bản đầy đủ: jsB@nk » Tính toán » Tính tiền trả góp 1
URL: https://www.javascriptbank.com/amortization-calculator.html



JavaScript
<script type="text/javascript">// Author Paul Baggethunfunction getAmortization(a,n,p) {var i=0;var sATline="";var oAmortizationTable=document.getElementById("amortizationtable");oAmortizationTable.style.visibility="visible";var sCR=String.fromCharCode(13);var sTab=String.fromCharCode(27);/* Calculate amortization and write table to text area **/var payment = getPayment(a,n,p);oAmortizationTable.value = sCR + "Monthly Payment = " + (Math.round(payment*100)/100) + sCR + sCR;oAmortizationTable.value += "Month  Balance    Principal  Interest  Payment    Total Interest" + sCR;var balance=a;var interest = 0.0;var principal=0.0;var totalinterest=0.0;for (i=1;i<=n;i++) {interest = balance*p/1200;totalinterest += interest;principal = payment-interest;balance -= principal;sATline = i.toString()+getSpaces(7-i.toString().length);sATline += Math.round(balance*100)/100;sATline += getSpaces(18-sATline.length);sATline += (Math.round(principal*100)/100);sATline += getSpaces(29-sATline.length);sATline += (Math.round(interest*100)/100);sATline += getSpaces(39-sATline.length);sATline += (Math.round(i*payment*100)/100);sATline += getSpaces(50-sATline.length);sATline += (Math.round(totalinterest*100)/100) + sCR;oAmortizationTable.value += sATline;}}function getSpaces(n) {var i=0; var sSpaces="";for (i=0;i<n;i++) {sSpaces += " ";}return sSpaces;}function getPayment(a,n,p) {/* Calculates the monthly payment from annual percentage   rate, term of loan in months and loan amount. **/var acc=0;var base = 1 + p/1200;for (i=1;i<=n;i++) { acc += Math.pow(base,-i); }return a/acc;}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<table cellpadding=2 style="border:2px outset;background-color:silver;font-size:smaller;"><tr> <td> Loan Amount <td> <input id=amountname=amount type=text value=6000 size=10><tr> <td> Interest Rate (APR)<td> <input id=apr name=apr type=text value=10.0 size=10><tr> <td> Term (months)<td> <input id=term name=term type=text value=24 size=10><tr> <td align=right colspan=2><buttononclick="getAmortization(document.getElementById('amount').value,document.getElementById('term').value,document.getElementById('apr').value)" width=100 height=50>Calculate</button></table><br><textarea id="amortizationtable" rows="16" cols="70" wrap="off"style="visibility:hidden;background-color:silver"></textarea><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->