Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (37 loc) · 1.59 KB
/
Copy pathscript.js
File metadata and controls
41 lines (37 loc) · 1.59 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
let myAccountBalance = parseInt(
document.getElementById("myAccountBalance").innerText
);
function sendMoney() {
var enterName = document.getElementById("enterName").value;
var enterAmount = parseInt(document.getElementById("enterAmount").value);
let createPTag = document.createElement("li");
var textNode = document.createTextNode(
`Successful transaction of Rs${enterAmount} is sent to recepient with Email-id ${enterName}@email.com on ${Date()}.`
);
createPTag.appendChild(textNode);
var element = document.getElementById("transaction-history-body");
element.insertBefore(createPTag, element.firstChild);
if (enterAmount > 8000) {
alert("Insufficient Balance.");
} else {
var findUserBankAccount = enterName + "BankBalance";
var finalAmount =
parseInt(document.getElementById(findUserBankAccount).innerHTML) +
enterAmount;
var myAccountBalance =
parseInt(document.getElementById("myAccountBalance").innerText) -
enterAmount;
document.getElementById("myAccountBalance").innerText = myAccountBalance;
document.getElementById(findUserBankAccount).innerHTML = finalAmount;
alert(
`Successful Transaction !! Rs${enterAmount} is sent to ${enterName}@email.com.`
);
// transaction history
var element = document.getElementById("transaction-history-body");
element.insertBefore(createPTag, element.firstChild);
createPTag.appendChild(textNode);
var element = document.getElementById("transaction-history-body");
element.insertBefore(createPTag, element.firstChild);
}
}
Footer;