-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
31 lines (29 loc) · 1.55 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
function sendMoney(){
var enterName = document.getElementById("enterName").value;
var enterAmount = parseInt(document.getElementById("enterAmount").value);
var enterSName = document.getElementById("enterSName").value;
var findSenderBankAccount = enterSName + "BankBalance";
var enterSAmount =parseInt(document.getElementById(findSenderBankAccount).innerHTML);
if (enterAmount > enterSAmount) {
alert("Insufficient Balance.")
}
else if(enterAmount >= 10000){
alert("Exceeded! Limit should be less than Rs 10,000")
}
else {
var findUserBankAccount = enterName + "BankBalance";
var finalAmount = parseInt(document.getElementById(findUserBankAccount).innerHTML) + enterAmount;
var myAccountBalance = parseInt(document.getElementById(findSenderBankAccount).innerHTML) - enterAmount;
document.getElementById(findSenderBankAccount).innerHTML = myAccountBalance;
document.getElementById(findUserBankAccount).innerHTML = finalAmount;
alert(`Successful Transaction !!
${enterAmount}/- is sent to ${enterName}@email.com.`)
// transaction history
var createPTag = document.createElement("li");
var textNode = document.createTextNode(`Rs ${enterAmount} is sent from the sender with Email-id ${enterSName}@email.com
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);
}
}