-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
31 lines (31 loc) · 1.1 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<script>
let timeout;
function optimisedInterest(){
clearTimeout(timeout);
timeout = setTimeout(function(){
interest();
},1000);
}
async function interest(){
let a = document.getElementById("principal").value;
let b = document.getElementById("rate").value;
let c = document.getElementById("time").value;
let response = await fetch("http://localhost:3005/interest?principal=" + a + "&rate=" + b + "&time=" + c)
let answer = await response.text();
document.getElementById("ans").innerHTML = answer;
}
</script>
<body>
<input oninput="optimisedInterest()" id = "principal" type="text" placeholder="Principal"><br><br>
<input oninput="optimisedInterest()" id = "rate" type="text" placeholder="Rate"><br><br>
<input oninput="optimisedInterest()" id = "time" type="text" placeholder="Time"><br><br>
<div id = "ans"></div>
</body>
</html>