-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloan.html
More file actions
83 lines (73 loc) · 2.15 KB
/
loan.html
File metadata and controls
83 lines (73 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loan Calculator</title>
<style>
body{
padding: 0;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Courier New', Courier, monospace;
}
.container{
margin: 10px;
background: #3d6d6d;
color: #000000bb;
padding: 20px;
border-radius: 10px;
}
.input{
width: 100%;
font-size: 20px;
height: 30px;
}
.payment{
font-weight: 600;
font-size: 20px;
}
button{
padding: 10px;
margin: 5px;
background-color: black;
border-radius: 8px;
color: white;
font-size: 20px;
border: 1px solid black;
}
</style>
</head>
<body>
<div class="container">
<h1>Loan Calculator</h1>
<p>Loan Amount $
<input onchange="calculateLoan()" class="input" type="number" id="loan-amount" min="1" max="500000" value="10000">
</p>
<p>Interest Rate %
<input onchange="calculateLoan()" class="input" type="number" id="interest-rate" min="0" max="100" value="10" step=".1">
</p>
<p>Months to pay
<input onchange="calculateLoan()" class="input" type="number" id="months-to-pay" min="6" max="48" value="12">
</p>
<p class="payment" id="payment">Monthly Payment:</p>
<button>calculate</button>
</div>
<script>
function calculateLoan() {
loanAmountValue = document.getElementById("loan-amount").value;
interestRateValue = document.getElementById("interest-rate").value;
MonthsToPayValue = document.getElementById("months-to-pay").value;
interest = (loanAmountValue * (interestRateValue * 0.01)) / MonthsToPayValue;
monthlyPayment = (loanAmountValue / MonthsToPayValue + interest).toFixed(2);
let btn = document.querySelector("button");
btn.addEventListener("click" , ()=>{
document.getElementById("payment").innerHTML = `Monthly Payment: ${monthlyPayment}`;
});
}
</script>
</body>
</html>