I have a form which displays a list of values as buttons.
products = [ant,bat,cat,dog,egg]
Index.html
<form action="{{ url_for('show_products') }}" method="post">
<ul class="list-group">
{% for p in products %}
<input type="submit" name="{{p}}" value="{{p}}" >{{p}}</input>
{% endfor %}
</ul>
<button type="submit" class="btn btn-primary">Want to use this button to redirect</button>
</form>
In app.py
@app.route('/show_products', methods=["POST", "GET"])
def show_products():
result = []
prod_data = {}
if request.form:
result = request.form
prod_data['p_name'] = result
return render('run_import.html', prod_data)
show_products.html
<h1>Hi</h1>
<p>p_name</p>
So everytime one of the products are clicked, ant, cat etc. The page immediately redirect to show_products.html and the name of the clicked product is shown.
I want the redirect to happen only when the button outside the for loop is clicked and every product that was clicked until then to be passed back as a list to show_products() and then to the html page.
index.htmltemplpate.checkboxto select multiple entries in a form and then one submit button. Would that help?