从复选框表格中获取输入

时间:2017-05-26 02:38:41

标签: python html flask

我正在编写一个烧瓶应用程序,并希望从与所选30分钟插槽相对应的复选框表中提取用户的可用性,如下面的代码片段所示。

<form method="POST" action="_avail" style="margin: 5% 5% auto 5%; overflow:auto">
    <div class="signup column">
        <table id="am">
        <tr style="background-color:transparent">
            <th style="background-color:transparent;border:none">AM</th>
            <th>Mo</th> <th>Tu</th> <th>We</th> <th>Th</th> <th>Fr</th>
        </tr>
        <tr>
            <th>08:00</th>
            <td><input type="checkbox" name="mo" value="8"></td>
            <td><input type="checkbox" name="tu" value="8"></td>
            <td><input type="checkbox" name="we" value="8"></td>
            <td><input type="checkbox" name="th" value="8"></td>
            <td><input type="checkbox" name="fr" value="8"></td>
        </tr>
        <tr>
            <th>:30</th>
            <td><input type="checkbox" name="mo" value="8:30"></td>
            <td><input type="checkbox" name="tu" value="8:30"></td>
            <td><input type="checkbox" name="we" value="8:30"></td>
            <td><input type="checkbox" name="th" value="8:30"></td>
            <td><input type="checkbox" name="fr" value="8:30"></td>
        </tr>
        </table>
    </div>
</form>

但是,当后端尝试从表中获取数据时,仅返回一周中每天的第一个选定插槽。根据我对表单的了解,我认为通过调用特定名称的请求将返回为该名称检查的所有值。是否有一些我忽略的HTML表格约定?

mon_avail = request.form.get('mo', '', type=str)
tue_avail = request.form.get('tu', '', type=str)
wed_avail = request.form.get('we', '', type=str)
thu_avail = request.form.get('th', '', type=str)
fri_avail = request.form.get('fr', '', type=str)

0 个答案:

没有答案
相关问题