Python检查单选按钮为True或False

时间:2019-12-15 08:02:48

标签: python html flask radio

我有一个包含正确答案的多项选择题(4个选择)的数据库。我把其中的10张放在页面上。

现在,当我单击“提交”按钮时,我想检查它们是否为True或False。我该怎么办?

我的代码在这里:

{% block content %}
{% set i = namespace(value=1) %}
{% for question in questions.items %} 
<form action="{{ url_for('result') }}" method="POST">
    <article class="media content-section">
        <div class="media-body">
            <h5 class="article-metadata">[{{ question.question_id }}] Câu {{ i.value }}</h5> <br>
            <p class="article-content">{{ question.content }}</p>

            <br>
            <div style="width: 50%;float: left;max-width: 50%; word-wrap: break-word;;">
                <label><input type="radio" name="optradio" value="A"> A. {{ question.key_A }}</label>
            </div>

            <div>
                <label><input type="radio" name="optradio" value="B"> B. {{ question.key_B }}</label>
            </div>

            <div style="width: 50%;float: left; max-width: 50%; word-wrap: break-word;">
                <label><input type="radio" name="optradio" value="C"> C. {{ question.key_C }}</label>
            </div>

            <div>
                <label><input type="radio" name="optradio" value="D"> D. {{ question.key_D }}</label>
            </div>

        </div>
    </article>
    {% set i.value = i.value +1 %}
    {% endfor %}
    <br>
    <div>
        <button class="btn btn-info" type="submit" value="Done!"
                style="margin-bottom: 15%;width: 25%;">Done!</button>
    </div>
</form>
{% endblock %}

0 个答案:

没有答案