update stock portfolio position function

This commit is contained in:
Justin 2023-07-11 18:25:44 +08:00 committed by GitHub
parent a627bf7f21
commit c3e6acdbde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2900,3 +2900,36 @@ function getCryptoSymbol(value) {
console.error('Error:', error);
});
}}
// update stock portfolio position with new values
function updateStockPorftolio() {
let update_stock_cost = document.getElementById('inputText9').value;
let update_stock_shares = document.getElementById('inputText8').value;
let update_symbol = document.getElementById('inputText3').value;
let update_stock_days = document.getElementById('inputText10').value;
let update_stock_settings = {
shares:update_stock_shares,
cost:update_stock_cost,
symbol:update_symbol,
days:update_stock_days,
};
if ((update_stock_shares !== '') && (update_stock_cost !== '') && (update_stock_days !== '') && (update_symbol !== '')) {
fetch("/savePortfolioSettings", {
method: "POST",
body: JSON.stringify(update_stock_settings),
});
document.getElementById('updated-stock-p').style.display = "block";
setTimeout(function hideElement() {
document.getElementById('updated-stock-p').style.display = "none";
}, 5000);
} else {
stockValidate();
}
}