如何获取是否在烧瓶上选中复选框 [英] How to get if checkbox is checked on flask
本文介绍了如何获取是否在烧瓶上选中复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Flask Python 中使用 Bootstrap.
request.form.get("name")#name 是表单元素的名称(复选框)<label class="btn btn-danger pzt active"><input type="checkbox" name="name" value="1" data-id="0">查看标签>
当复选框被选中时,父标签具有活动"类,我想知道是否选中了复选框.有什么办法吗?
解决方案
您可以尝试以下操作:
HTML:<div class="checkbox"><标签><input type="checkbox" name="check" value="edit">新的条目标签>
在烧瓶中:
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屋!
查看全文