我有一个 Flask 模板,它显示一个页面,其中包含一个dropdown列表owners,一个table包含所有者的输赢记录,以及一个radio在regular赛季记录和playoff记录之间切换的页面。所需的工作流程是:如果通过导航栏导航到页面,它应该默认为/matchup-history/regular。(这有效)否则,无论何时radio切换,它都应该相应地路由。(这不起作用)比赛历史.html{%- extends "base.html" -%}{% block nav_matchups %}active{% endblock %}{%- block content -%} <form action="{{ url_for('show_matchup_history', matchup_type=request.form['matchup_type']) }}" method="post"> <label> <select name="owner_id" onchange="this.form.submit()"> {%- for o in owners %} {%- if request.form['owner_id'] == o['owner_id']|string() %} <option value="{{ o['owner_id'] }}" selected>{{o['first_name'] + " " + o['last_name'] }}</option> {%- else %} <option value="{{ o['owner_id'] }}">{{o['first_name'] + " " + o['last_name'] }}</option> {%- endif %} {%- endfor %} </select> </label> {% block matchup_type_radio %}{% endblock %} </form> {%- if records|length > 0 %} <div class="stats-table"> <table> <tr> {%- for th in table_headers %} <th>{{ th }}</th> {%- endfor %} </tr> {%- for r in records %} <tr> {%- for cn in column_names %} <td>{{ r[cn] }}</td> {%- endfor %} </tr> {%- endfor %} </table> </div> {%- endif %}{% endblock -%}比赛历史/regular.html{%- extends "matchup-history.html" -%}{% block matchup_type_radio %}<label><input type="radio" name="matchup_type" value="regular" onclick="this.form.submit()" checked>Regular Season</label><label><input type="radio" name="matchup_type" value="playoffs" onclick="this.form.submit()">Playoffs</label>{% endblock %}比赛历史/playoffs.html{%- extends "matchup-history.html" -%}{% block matchup_type_radio %}<label><input type="radio" name="matchup_type" value="regular" onclick="this.form.submit()">Regular Season</label><label><input type="radio" name="matchup_type" value="playoffs" onclick="this.form.submit()" checked>Playoffs</label>{% endblock %}
添加回答
举报
0/150
提交
取消