flask多选框怎么实现[Flask框架]
一、 文本域和单选按钮
前端 文本域和单选按钮表单获取方法一样
<form class="form-horizontal" method="post"><div class="form-group">
<label for="username" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="username" name="username" placeholder="Username" autofocus="" >
</div>
</div>
....
...
<div class="row">
<div class="col-sm-2 col-sm-offset-2">
<input name="sex" value="M" type="radio" checked="checked"> 男
</div>
<div class="col-sm-2 ">
<input name="sex" value="F" type="radio"> 女
</div>
</div>
</form>
文本
pyhon 后端用request.values.get("name") 去获取
if request.method == "POST":username = request.values.get("username")
sex = request.values.get("sex")
二、多选按钮checkbox
<div class="row"><div class="col-sm-2 ">
<label>
<input name="s_option" value="basketball" type="checkbox"> 篮球
</label>
</div>
<div class="col-sm-2 ">
<label>
<input name="s_option" value="football" type="checkbox"> 足球
</label>
</div>
<div class="col-sm-2 ">
<label>
<input name="s_option" value="badminton" type="checkbox"> 羽毛球
</label>
</div>
</div>
以上是 flask多选框怎么实现[Flask框架] 的全部内容, 来源链接: utcz.com/z/521757.html