flask-bootstrap

populate WTForms select field using value selected from previous field

余生长醉 提交于 2019-11-28 06:01:51
New to this, trying to build an app following a well known Flask tutorial, using Flask-bootstrap, Flask-wtforms, Jinja etc I have a form with 2 select fields and a button. class Form(FlaskForm): school_year = SelectField('School year', choices=some_tuples_list) category = SelectField('Category', choices=[]) submit = SubmitField('submit') I want only the first field to be pre-populated, and the other to get populated (on the client side?) based on the previous field's selected value. In the template I try something like {{ form.school_year(**{"onchange":"getCategories()"}) }} which works ok

populate WTForms select field using value selected from previous field

荒凉一梦 提交于 2019-11-27 01:03:10
问题 New to this, trying to build an app following a well known Flask tutorial, using Flask-bootstrap, Flask-wtforms, Jinja etc I have a form with 2 select fields and a button. class Form(FlaskForm): school_year = SelectField('School year', choices=some_tuples_list) category = SelectField('Category', choices=[]) submit = SubmitField('submit') I want only the first field to be pre-populated, and the other to get populated (on the client side?) based on the previous field's selected value. In the