Answer the question
In order to leave comments, you need to log in
How do I pass a list of values through Flask's checkbox?
I have a table that is generated from a database. I need to get all the values of checked fields in a checkbox. But I can only send one value. Here is the code that generates the table from the database:
<div>
<form name="markers" method="post">
<button type="submit" name="marker">Маркировки</button>
</form>
</div>
{% for item in awaiting_deliver %}
<tr>
<form name="markers" method="post">
<td>
<input class="form-check-input" type="checkbox" name="check_box" value="{{ item.posting_number }}">
</td>
</form>
<td class="text-muted">{{ item.shipment_date }}</td>
{% endfor %}
{% for item in awaiting_deliver %}
<tr>
<form name="markers" method="post">
<td>
<input class="form-check-input" type="checkbox" name="check_box" value="{{ item.posting_number }}">
<button type="submit" name="marker">Маркировки</button>
</td>
</form>
<td class="text-muted">{{ item.shipment_date }}</td>
{% endfor %}
if "marker" in request.form:
markers = request.form.getlist("check_box")
print(markers)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question