-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpurchase.html
92 lines (84 loc) · 4.15 KB
/
purchase.html
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
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<title>Hire Purchase Calculator</title>
<link rel="stylesheet" type="text/css" href="index.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light" style="background-color: #e3f2fd;">
<a class="navbar-brand" href="#">Home</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="./index.html">Financial Calculator <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="./purchase.html">Hired purchase</a>
</li>
</ul>
</div>
</nav>
<div id="divForm" class="card w-50">
<div class="card-body">
<h1 id="title" class="card-title">Hire Purchase Calculator</h1>
<form id="form" onsubmit="return false;">
<div class="form-group row">
<label class="col-sm-3 col-form-label">Price</label>
<div class="col-sm-9">
<input id="txtPrice" type="number" value="10000" class="form-control" required>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Deposit</label>
<div class="col-sm-9">
<input id="txtDeposit" type="number" value="1000" class="form-control" required>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Interest Rate</label>
<div class="col-sm-9">
<input id="txtInterest" type="number" value="3" class="form-control" required>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 col-form-label">Years of Installment</label>
<div class="col-sm-9">
<input id="txtYears" type="number" value="5" class="form-control" required>
</div>
</div>
<button id="btnSubmit" class="btn btn-success" type="submit">Submit</button>
<button type="reset" class="btn btn-outline-secondary">Reset</button>
</form>
<div id="divBalance" class="card">
<div class="card-header">
Amount to be paid
</div>
<div class="card-body">
<blockquote class="blockquote mb-0">
Amount: $<span id="txtVal">0</span>
</blockquote>
</div>
</div>
</div>
</div>
<script>
btnSubmit.addEventListener("click", caculate);
var txtPrice = document.getElementById("txtPrice").getAttribute("value");
var txtDeposit = document.getElementById("txtDeposit").getAttribute("value");
var txtInterest = document.getElementById("txtInterest").getAttribute("value");
var txtYears = document.getElementById("txtYears").getAttribute("value");
var loan, interestamt, total, monthlypayment
function caculate(){
loan = txtPrice - txtDeposit;
interestamt = (loan * txtInterest / 100) * txtYears;
total = interestamt + loan;
monthlypayment = total / (txtYears * 12);
document.getElementById("txtVal").innerHTML = monthlypayment;
}
</script>
</body>
</html>