I'm currently working on my first python flask website. So I'm struggling with a basic task :-)
I have two comboboxes on my page (lets say comboboxes A (brands) and B (models)). When the website is loaded, A gets filled. B depends on A, which means that when I choose a value on A, B should get loaded accordingly. My problem is that I don't know how to call a function to load B. I would appreciate any advice, thanks.
#PYTHON
#load data for Combobox A
@app.route('/')
def home():
connection = pypyodbc.connect('Driver={SQL Server};Server=localhost;Database=Demo')
cursor = connection.cursor()
cursor.execute("select Brand from [dbo].[CarBrands]")
data = cursor.fetchall()
brands = []
for val in data:
brands.append(val[0])
return render_template("home.html",brands=brands)
#HTML
#Display A
#Load B according to A
{% extends "layout.html" %}
{% block content %}
<div class="home">
<h1>Demo</h1>
<p>Test</p>
</div>
<select>
{% for item in brands %}
<option value={{item}}>{{item}}</option><br>
{% endfor %}
</select>
<select>
{% for item in models %}
<option value={{item}}>{{item}}</option><br>
{% endfor %}
</select>
{% endblock %}