-
Notifications
You must be signed in to change notification settings - Fork 0
/
sum.html
26 lines (24 loc) · 834 Bytes
/
sum.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
<html>
<script>
let timeout;
function debounce(){
clearTimeout(timeout);
setTimeout(function(){
populateDiv()
},1000)
}
async function populateDiv(){
const number=document.querySelectorAll("input")
const a=number[0].value
const b=number[1].value
const response=await fetch("http://localhost:3000/sum?a="+a+"&b="+b)
const ans=await response.text()
document.getElementById("finalsum").innerHTML=ans
}
</script>
<body>
<input oninput="debounce()" type="text" placeholder="first number"></input><br></br>
<input oninput="debounce()" type="text" placeholder="second number"></input><br></br>
<div id="finalsum"></div>
</body>
</html>