Mortgage Calculator
Mortgage Calculator with Monthly Loan Payment, Total Payment and Total Interest Payment
HTML
<title>
Mortgage Calculator (I smell Bay CON)
</title>
<style>
.result {
font-weight: bold;
}
#payment {
text-decoration: underline;
}</style>
<form name="loandata">
<table>
<tr><td><b>Enter Loan Information:</b></td></tr>
<tr>
<td>1) Amount of the loan (any currency):</td>
<td><input type="text" name="principal" onchange="calculate();"></td>
</tr>
<tr>
<td>2) Annual percentage rate of interest:</td>
<td><input type="text" name="interest" onchange="calculate();"></td>
</tr>
<tr>
<td>3) Repayment period in years:</td>
<td><input type="text" name="years" onchange="calculate();"></td>
</tr>
<tr><td></td>
<td><input type="button" value="Compute" onclick="calculate();"></td>
</tr>
<tr><td><b>Payment Information:</b></td></tr>
<tr>
<td>4) Your monthly payment:</td>
<td>$<span class="result" id="payment"></span></td>
</tr>
<tr>
<td>5) Your total payment:</td>
<td>$<span class="result" id="total"></span></td>
</tr>
<tr>
<td>6) Your total interest payments:</td>
<td>$<span class="result" id="totalinterest"></span></td>
<p>
For number 1, Do not use comma, enter number only ex.<strong> 500000</strong> (Five Hundred Thousand)
</p>
<p>
For number 2, enter number only, no percentage sign i.e,<strong> 5.5 </strong>(Five and a half %)
</p>
<p>
For number 3, enter number only, ex.<strong> 25</strong> (for twenty five years)
</p>
</tr>
</table>
</form>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function calculate() {
// Get the user's input from the form. Assume it is all valid.
// Convert interest from a percentage to a decimal, and convert from
// an annual rate to a monthly rate. Convert payment period in years
// to the number of monthly payments.
var principal = document.loandata.principal.value;
var interest = document.loandata.interest.value /...
CSS
.result {
font-weight: bold;
}
#payment {
text-decoration: underline;
}