I have two select fields in html form and i would like to set my options according to a table in my mssql database
I have created a connection using SQLAlchemy:
Server='MYLAPTOP'
Database="master"
Driver='ODBC Driver 17 for SQL Server'
Database_Con=f'mssql://@{Server}/{Database}?driver={Driver}'
engine = create_engine(Database_Con)
con = engine.connect()
and this is my html form :
<form method=post enctype=multipart/form-data>
Choose primary subject:
<select id="primary" name="primary"
</select>
<hr />
Choose secondary subject:
<select id="secondary" name="secondary"></select>
<hr />
<div class="mb-3">
<input type=File name=File>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
and this is how I get the table:
df = pd.read_sql_query("select * from Data_Tables",con)
print(df)
my table:
Name Primary Secondary
1 A B C
2 D B E
3 X D V
4 F G N
5 L G V
I want that in "primary" select field the options will be :B,D,G and according to the first selection in "primary" field the options will change if i choose B the options will be E,C if I choose G then N,V will appear and for D it will be V