I am new to HTML so having a bit of an issue with passing a value from HTML to python function. So what I am doing is making buttons with a loop, code is following:
Python Code for making buttons:
@app.route('/Ongoing', methods=['POST', 'GET'])
def Ongoing():
id = ['1', '2', '3', '4', '5', '6', '7', '8']
length = 8
return render_template('Run.html', length=length, id=id)
Html code for Buttons:
{% for i in range(length) %}
<form id="btn" action="{{ url_for('detail') }}" method="GET">
<button type="submit" class="submit-btn-choice" style="margin-top: 20px;">Name</button>
</form>
{%endfor%}
Now I have 8 buttons. So what I want is when I press the first button first value of id which is 1 should be sent back to the called function(detail). In the same way when the second button is pressed value of 2 is sent back with it.
The function to which value is send is following:
@app.route('/detail', methods=['POST', 'GET'])
def detail(id):
response = Coup_data(id)
return render_template('detail.html', response =response )
I would really appreciate the help. Thanks