-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
54 lines (50 loc) · 1.71 KB
/
script.js
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
let total=10000;
const displayForm=()=>{
document.getElementById("checkBalance").style.display="none";
document.getElementById("transfer").style.display="block";
}
const display=(check)=>{
if(check==="negative"){
document.getElementById("negative").style.display="block";
document.getElementById("positive").style.display="none";
}
else{
document.getElementById("negative").style.display="none";
document.getElementById("positive").style.display="block";
}
}
const cancel=(check)=>{
if(check==="transfer")
document.getElementById("transfer").style.display="none";
if(check==="negative"){
document.getElementById("negative").style.display="none";
}
if(check==="positive"){
document.getElementById("positive").style.display="none";
}
}
const sendData=()=>{
// alert("sendData");
const user=document.getElementById("name").value;
const amount=parseInt(document.getElementById("amount").value);
if(amount>total){
display("negative");
}
else{
const balance=parseInt(document.getElementById(user).innerText)+amount;
// alert("sendData: "+user+" : "+balance);
total-=amount;
document.getElementById(user).innerText=balance;
display("positive");
if(user)
cancel("transfer");
}
}
// modal to check
const checkBalance=()=>{
document.getElementById("negative").style.display="none";
document.getElementById("positive").style.display="none";
document.getElementById("checkBalance").style.display="block";
document.getElementById("transfer").style.display="none";
document.getElementById("total").innerText=total;
}