0% found this document useful (0 votes)
12 views3 pages

New Form Java

Uploaded by

abhishekg7832
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

New Form Java

Uploaded by

abhishekg7832
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

let currentBalance = 0.

00;
let depositHistory = [];
let withdrawalHistory = [];

function toggleOptions() {
const moneyActions = document.getElementById('moneyActions');
moneyActions.style.display = moneyActions.style.display === 'none' ? 'flex' :
'none';
document.getElementById('currentBalance').textContent =
currentBalance.toFixed(2);
document.getElementById('historySection').style.display = 'none'; // Hide
history when options are shown
}

function refreshBalance() {
alert('Balance refreshed!');
document.getElementById('currentBalance').textContent =
currentBalance.toFixed(2);
}

function showDepositOptions() {
document.getElementById('depositOptions').style.display = 'block';
document.getElementById('historySection').style.display = 'none'; // Hide
history when showing deposit options
}

function selectAmount(amount) {
document.getElementById('amount').value = amount;
}

function showDepositForm() {
const depositAmount = document.getElementById('amount').value;
if (depositAmount) {
document.getElementById('depositForm').style.display = 'block';
document.getElementById('depositForm').classList.add('show-form');
document.getElementById('depositOptions').style.display = 'none'; // Hide
deposit options
} else {
alert('Please select an amount.');
}
}

function submitDeposit() {
const name = document.getElementById('name').value;
const accountNumber = document.getElementById('accountNumber').value;
const paymentMethod = document.getElementById('paymentMethod').value;
const amount = parseFloat(document.getElementById('amount').value);

if (amount > 0) {
currentBalance += amount;
depositHistory.push({ name, accountNumber, paymentMethod, amount });
alert('Deposit successful!');

// Update deposit history


updateDepositHistory();

// Reset and hide forms


resetDepositForm();
refreshBalance();
document.getElementById('historySection').style.display = 'block'; // Show
history after deposit
} else {
alert('Invalid amount.');
}
}

function resetDepositForm() {
document.getElementById('depositForm').reset();
document.getElementById('depositForm').style.display = 'none';
document.getElementById('depositOptions').style.display = 'none'; // Hide
deposit options
}

function showWithdrawalForm() {
document.getElementById('withdrawalForm').style.display = 'block';
document.getElementById('historySection').style.display = 'none'; // Hide
history when showing withdrawal form
}

function submitWithdrawal() {
const withdrawName = document.getElementById('withdrawName').value;
const withdrawAccountNumber =
document.getElementById('withdrawAccountNumber').value;
const withdrawMethod = document.getElementById('withdrawMethod').value;
const withdrawAmount =
parseFloat(document.getElementById('withdrawAmount').value);

if (withdrawAmount > 0 && withdrawAmount <= currentBalance) {


currentBalance -= withdrawAmount;
withdrawalHistory.push({ withdrawName, withdrawAccountNumber,
withdrawMethod, withdrawAmount });
alert('Withdrawal successful!');

// Update withdrawal history


updateWithdrawalHistory();

// Reset and hide forms


resetWithdrawalForm();
refreshBalance();
document.getElementById('historySection').style.display = 'block'; // Show
history after withdrawal
} else {
alert('Invalid withdrawal amount.');
}
}

function resetWithdrawalForm() {
document.getElementById('withdrawalForm').reset();
document.getElementById('withdrawalForm').style.display = 'none';
}

function updateDepositHistory() {
const depositHistoryList = document.getElementById('depositHistoryList');
depositHistoryList.innerHTML = '';
depositHistory.forEach(entry => {
const listItem = document.createElement('li');
listItem.textContent = `Name: ${entry.name}, Amount: ₹${entry.amount},
Method: ${entry.paymentMethod}`;
depositHistoryList.appendChild(listItem);
});
}

function updateWithdrawalHistory() {
const withdrawalHistoryList = document.getElementById('withdrawalHistoryList');
withdrawalHistoryList.innerHTML = '';
withdrawalHistory.forEach(entry => {
const listItem = document.createElement('li');
listItem.textContent = `Name: ${entry.withdrawName}, Amount: ₹$
{entry.withdrawAmount}, Method: ${entry.withdrawMethod}`;
withdrawalHistoryList.appendChild(listItem);
});
}

function goBackToMain() {
document.getElementById('depositForm').style.display = 'none';
document.getElementById('withdrawalForm').style.display = 'none';
document.getElementById('depositOptions').style.display = 'none'; // Hide
deposit options
document.getElementById('historySection').style.display = 'block'; // Show
history again
}

function filterHistory(type) {
alert(`Filtering ${type} history...`);
}

function exitSite() {
window.close(); // This will work in some browsers
}

You might also like