so my html page is this and it has 2 FORMS, both using method post
{% extends "layout.html" %}
{% block main %}
<h1>Search for a <strong>STOCK</strong></h1>
<br>
<form action="/buy" method="POST">
<input type="text" autofocus name="symbol" id="symbol" placeholder="Write a stock quote">
<input type="submit" value="find">
</form>
<hr >
<br>
<div class="table-responsive -sm">
<h2>Details about the Stock</h2>
<br>
<table class="table align-middle">
<thead>
<tr>
<th>Company Name</th>
<th>Price</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ name }}</td>
<td>{{ price }}</td>
<td>{{ symbol }}</td>
<td><form action ="/buy" method = "POST">
<input type= "number" id="shares" name="shares" placeholder="number of shares" required min=1 >
<input type="submit" value ="BUY">
</form></td>
</tr>
</tbody>
</table>
</div>
{% endblock %}
this is part of my app.py where are my requests
@app.route("/buy", methods=["GET", "POST"])
@login_required
def buy():
"""Buy shares of stock"""
if request.method == "POST":
symbol = request.form.get("symbol")
if not symbol:
return apology("Must give symbol")
else:
stock = lookup(symbol.upper())
if stock == None:
return apology("Symbol doesnt exist")
cash = db.execute("SELECT cash FROM users WHERE id = ?", session["user_id"])
shares = request.form.get("shares")
return render_template("buy.html", name=stock["name"], price = stock["price"] ,
symbol = stock["symbol"] )
return render_template("buy.html")
When i submit the first form to search for a stock it calls also the other form and i cant find a way to submit each form separately.
How can i call them separately?