Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Sell Stock" Functionality #71

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ <h2>Buy Stock</h2>
<button type="submit">Buy Stock</button>
</form>

<!-- New Sell Stock Form -->
<form id="sellStockForm">
<h2>Sell Stock</h2>
<input type="text" name="stockName" placeholder="Stock Name" required>
<input type="number" name="quantity" placeholder="Quantity to Sell" required>
<button type="submit">Sell Stock</button>
</form>
<!-- New Actions -->
<div class="button-group">
<button id="viewOwnershipBtn">View Ownership</button>
Expand Down Expand Up @@ -313,6 +320,18 @@ <h2>Buy Stock</h2>
alert('Stock purchased successfully!');
});

// Handle Sell Stock Form submission
document.getElementById('sellStockForm').addEventListener('submit', async (event) => {
event.preventDefault();
const stockName = event.target.stockName.value;
const quantity = event.target.quantity.value;
// Here you would typically check the user's balance for the stock and proceed with the sale
// Simulating a successful sale for demonstration purposes
alert(`Successfully sold ${quantity} shares of ${stockName}!`);
console.log(`Selling Stock: ${stockName}, Quantity: ${quantity}`);
});


// Button actions
document.getElementById('viewOwnershipBtn').addEventListener('click', () => {
alert('Feature not implemented yet!');
Expand Down
Loading