pythonflask框架后端如何获取前端的表单数据⽂本单选框多选
框
转载:
⼀、⽂本域和单选按钮
前端 ⽂本域和单选按钮表单获取⽅法⼀样
<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 后端⽤("name") 去获取
hod == "POST":
username = ("username")
sex = ("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>
后端使⽤list("s_option") 去获取,获取的value会组成⼀个列表htmlradio多选怎么用
s_option = list("s_option")
for s in s_option:
pass
三、select 下拉框
前端表现形式
<select class="form-control" name="manufacturer" id="manufacturer"> <option></option>
<option selected="selected">--请选择⼚家--</option>
<option >HP</option>
<option >Huawei</option>
<option >Inspur</option>
</select>
pyhon 后端也是⽤("name") 去获取
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论