let totalInvestment = 0; let transactionCount = 0; function lockInInvestment() { const predefinedAmounts = document.getElementById('predefined-amounts'); const selectedAmount = parseFloat(predefinedAmounts.value); if (isNaN(selectedAmount) || selectedAmount <= 0) { alert('Please select a valid investment amount.'); return; } // Get the current date and time in the format "DD/MM/YYYY" const currentDate = new Date(); const day = currentDate.getDate().toString().padStart(2, '0'); const month = (currentDate.getMonth() + 1).toString().padStart(2, '0'); const year = currentDate.getFullYear(); const transactionDateTime = `${day}/${month}/${year} ${currentDate.toLocaleTimeString()}`; // Add logic to handle the investment, update the portfolio, etc. totalInvestment += selectedAmount; // Add a row to the portfolio table with transaction date and time addPortfolioRow(`Transaction ${++transactionCount} (${transactionDateTime})`, selectedAmount); // Update the total portfolio amount updatePortfolioAmount(); } function addPortfolioRow(investmentType, amount) { const portfolioTable = document.getElementById('portfolio-body'); const newRow = portfolioTable.insertRow(); const investmentCell = newRow.insertCell(0); const amountCell = newRow.insertCell(1); investmentCell.textContent = investmentType; amountCell.textContent = '$' + amount.toFixed(2); } function updatePortfolioAmount() { const portfolioAmount = document.getElementById('portfolio-amount'); // Increment the total investment by 0.001% every 10 seconds setInterval(() => { const increasePercentage = 0.001; const increasedAmount = totalInvestment * (increasePercentage / 100); totalInvestment += increasedAmount; portfolioAmount.textContent = '$' + totalInvestment.toFixed(2); // Add animation class for a brief scale effect portfolioAmount.classList.add('increaseAmount'); setTimeout(() => { portfolioAmount.classList.remove('increaseAmount'); }, 300); }, 10000); } // Call the updatePortfolioAmount function to start the updating process updatePortfolioAmount();