FULL STACK   ·   UI   ·   UX   ·   GRAPHICS   ·   DEVELOPER   ·   INSTRUCTOR

Adam Khoury

Donate funds to show love and support

Click the button below to donate funds securely online. You can use your PayPal account or a credit card.

Your donations help free up my time to produce more content and assist in covering server costs. It's also a great way to say thanks for the content!

Application Configuration

Adam will be adding options here soon.

Monthly Payment Loan Calculator Form Programming Tutorial

Published :
Author :
Adam Khoury
Learn to program a Monthly Payment Loan Calculator with simple interest calculations included. The JavaScript logic can be used with or without value gathering form controls. In this tutorial we are adding the HTML form elements that will gather values needed by the script. <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script> // This script is explained line by line in depth in the following video: // http://www.developphp.com/view.php?tid=1389 function computeLoan(){ var amount = document.getElementById('amount').value; var interest_rate = document.getElementById('interest_rate').value; var months = document.getElementById('months').value; var interest = (amount * (interest_rate * .01)) / months; var payment = ((amount / months) + interest).toFixed(2); payment = payment.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); document.getElementById('payment').innerHTML = "Monthly Payment = $"+payment; } </script> </head> <body> <p>Loan Amount: $<input id="amount" type="number" min="1" max="1000000" onchange="computeLoan()"></p> <p>Interest Rate: <input id="interest_rate" type="number" min="0" max="100" value="10" step=".1" onchange="computeLoan()">%</p> <p>Months: <input id="months" type="number" min="1" max="72" value="1" step="1" onchange="computeLoan()"></p> <h2 id="payment"></h2> </body> </html>