如何获得复选框是否在烧瓶上被选中 [英] How to get if checkbox is checked on flask

查看:130
本文介绍了如何获得复选框是否在烧瓶上被选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Bootstrap和Flask Python。

$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ request $

< label class =btn btn-danger pzt active>
< input type =checkboxname =namevalue =1data-id =0>检查
< / label>

当复选框被选中时,父标签具有类active,我想得到如果复选框是检查。有没有什么办法或方法?

解决方案

您可以尝试以下操作:

  HTML:

< div class =checkbox>
< label>
< input type =checkboxname =checkvalue =edit>新条目
< / label>
< / div>

在烧瓶中:

  value = request.form.getlist('check')

你的复选框的值。这里的值将是一个列表。

  value = [u'edit'] 

您还可以获得具有相同名称属性的多个复选框的值。


I'm using Bootstrap with Flask Python.

 request.form.get("name")
 #name is the name of the form element(checkbox)

 <label class="btn btn-danger pzt active">
     <input type="checkbox" name="name" value="1" data-id="0"> Check
 </label>

When checkbox is checked, parent label has class "active", I want to get if checked box is checked. Is there any way or methods?

解决方案

you can try the following:

HTML:

<div class="checkbox">
<label>
    <input type="checkbox" name="check" value="edit"> New entry
</label>
</div>

In flask:

 value = request.form.getlist('check') 

This will give you the value of the the checkbox. Here value will be a list.

value = [u'edit']

You can also get value of multiple checkboxes with same name attribute.

这篇关于如何获得复选框是否在烧瓶上被选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆