如何请求 select 标签名称选择,而不是烧瓶中的值选择?
How to request for select tag name choice, not a value choice in flask?
假设您在 HTML 中有以下表格:
<form method="POST">
<select class="form-control" id="startyear" name="startyear">
<option value="2005">first</option>
<option value="2006">second</option>
<option value="2007">third</option></select>
</form>
我知道要访问烧瓶中 select 字段的 值 需要请求:
len = request.form.get(startyear)
然而,通过这种方式,我们可以获得值,因此“2005”、“2006”等。有没有办法获取这些值的名称?那么 "first"、"second" 等等?
谢谢
您可以在此处找到详细信息select developer.Mozilla
Each option element should have a value attribute containing the data value to submit to the server when that option is selected; if no value attribute is included, the value defaults to the text contained inside the element
所以获取文本:不要设置值,如果你设置了值你就会得到它
假设您在 HTML 中有以下表格:
<form method="POST">
<select class="form-control" id="startyear" name="startyear">
<option value="2005">first</option>
<option value="2006">second</option>
<option value="2007">third</option></select>
</form>
我知道要访问烧瓶中 select 字段的 值 需要请求:
len = request.form.get(startyear)
然而,通过这种方式,我们可以获得值,因此“2005”、“2006”等。有没有办法获取这些值的名称?那么 "first"、"second" 等等? 谢谢
您可以在此处找到详细信息select developer.Mozilla
Each option element should have a value attribute containing the data value to submit to the server when that option is selected; if no value attribute is included, the value defaults to the text contained inside the element
所以获取文本:不要设置值,如果你设置了值你就会得到它