I'm wondering why this isn't working as planned. The table below is in a form. Every table row has a book id and book title. The book title is formatted as a button, so that I can use the post method on form submission. When the button is clicked, the method (as shown below) fires well enough, but the book id isn't passed along to the method. I need the book id passed to the underlying method, as it will be used in a SQL query. Is there a way for me to make this happen?
{% block body %}
<div class="align-center">
<form action="{{ url_for('books') }}" method="post">
<table class="table">
<thead>
<tr>
<th></th>
<th>Book ID</th>
<th>ISBN #</th>
<th>Title</th>
<th>Author</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6"></td>
</tr>
</tfoot>
{% for book in books %}
<tr>
<td></td>
<td name="bookid">{{ book.id }}</td>
<td name="bookisbn">{{ book.isbn }}</td>
<td name="booktitle"><button btn style="border:none; border-bottom: 1px solid black;">{{ book.title }}</button></td>
<td name="bookauthor">{{ book.author }}</td>
</tr>
{% endfor %}
</table>
</form>
</div>
{% endblock %}
And here's the Flask method to which I'm posting:
@app.route("/books", methods=["POST"])
@login_required
def books():
bookid = request.form.get("bookid")
return render_template("books.html", message=bookid)