I'm building my first app and got to point where I want to dynamically refresh my table when I chose some value from the drop down list. I'm using Flask with SQLAlchemy
I have query where all my users are listed:
customers = Customer.query.all()
and in my html page I created a dropdown list
{% for x in customers %}
<option>{{ x.name }}</option>
{% endfor %}
depending on the chosen value I want to automatically generate a table bellow from another query without using a submit button:
invoice = Invoice.query.filter_by(customer="chosen value").all()
and in the html:
<table >
<thead>
<tr>
<th>Description</th>
<th>Date</th>
<th>number</th>
<th>sum</th>
</tr>
</thead>
<tbody>
{% for i in invoice %}
<tr>
<td>{{ invoice.description }}</td>
<td>{{ invoice.date }}</td>
<td>{{ invoice.number }}</td>
<td>{{ invoice.sum }}</td>
</tr>
{% endfor %}
</tbody>
</table>
I know that for this option I need to use jquery and found some examples but couldn't figure out how to twist them for my solution.