-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (37 loc) · 1.27 KB
/
Copy pathscript.js
File metadata and controls
41 lines (37 loc) · 1.27 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
function amountChange() {
document.getElementById("txtAmount").value =
document.getElementById("amountRange").value;
}
function yearChange() {
document.getElementById("txtYear").value =
document.getElementById("yearRange").value;
}
function interestChange() {
document.getElementById("txtInterest").value =
document.getElementById("interestRange").value;
}
function calculate() {
// r = r / (12 * 100); // one month interest
// t = t * 12; // one month period
// emi = (p * r * pow(1 + r, t)) / (pow(1 + r, t) - 1);
var p = parseFloat(document.getElementById("txtAmount").value);
var r = parseFloat(document.getElementById("txtInterest").value);
var y = parseFloat(document.getElementById("txtYear").value);
r = r / (12 * 100);
y = y * 12;
var emi = (p * r * Math.pow(1 + r, y)) / (Math.pow(1 + r, y) - 1);
document.getElementById("result").innerHTML =
"₹" + Math.round(emi);
}
function updateAmount() {
document.getElementById("amountRange").value =
document.getElementById("txtAmount").value;
}
function updateYear() {
document.getElementById("yearRange").value =
document.getElementById("txtYear").value;
}
function updateInterest() {
document.getElementById("interestRange").value =
document.getElementById("txtInterest").value;
}