[英]HTML form fields are set but empty
I have a normal HTML form which is submitted via POST. 我有一个通过POST提交的普通HTML表单。 The submit works and also sends data to the receiver page. 提交工作并且还将数据发送到接收者页面。 What confuses me the most, is, that the save-button and the hidden input (shop_id) are sent but not the selected options from the drop down. 最让我困惑的是,发送了保存按钮和隐藏的输入(shop_id),但没有发送下拉菜单中的所选选项。
The selects are in the post, but the values are empty. 选择在帖子中,但是值是空的。 The post looks like this: 该帖子看起来像这样:
save:Speichern
data[58]:
data[60]:
data[61]:
shop_id:5
Does anyone know how this can happen? 有人知道这怎么可能吗?
<form action="article.mapping.html" method="post"> <table class="table table-bordered table-hover" style="table-layout: fixed; min-width: 1871px;"> <colgroup> <col style="width: 268px;"> <col style="width: 267px;"> <col style="width: 266px;"> <col style="width: 267px;"> <col style="width: 804px;"> </colgroup> <thead> <tr class="size-row" style="height: 51.5px;"> <th class="floatThead-col" style="height: 51.5px;"></th> <th class="floatThead-col" style="height: 51.5px;"></th> <th class="floatThead-col" style="height: 51.5px;"></th> <th class="floatThead-col" style="height: 51.5px;"></th> <th class="floatThead-col" style="height: 51.5px;"></th> </tr> </thead> <tbody> <tr> <td colspan="5" class="text-center bg-info"><strong>Beck's</strong></td> </tr> <tr> <td>Beck's</td> <td>Gold</td> <td>24</td> <td>0.33</td> <td> <select name="data[58]" class="form-control" data-live-search="true" data-actions-box="true" title="Bitte wählen..."> <option value="">Bitte wählen...</option> <option value="">Becks Alkoholfrei 24x0.33l</option> <option value="">Becks Sixpack 24x0.33l</option> <option selected="selected" value="">Beck's Gold Sixpack 24x0.33l</option> <option value="">Beck's Green Lemon Sixpack 24x0.33l</option> <option value="">Beck's Ice 24x0.33l</option> <option value="">Beck's 24x0.33l</option> <option value="">Beck's Gold 24x0.33l</option> <option value="">Beck`s Green Lemon 24x0.33l</option> <option value="">Becks Red Ale 4-Pack 24x0.33l</option> </select> </td> </tr> <tr> <td>Beck's</td> <td>Green Lemon</td> <td>24</td> <td>0.33</td> <td> <select name="data[60]" class="form-control" data-live-search="true" data-actions-box="true" title="Bitte wählen..."> <option value="">Bitte wählen...</option> <option value="">Becks Alkoholfrei 24x0.33l</option> <option value="">Becks Sixpack 24x0.33l</option> <option value="">Beck's Gold Sixpack 24x0.33l</option> <option selected="selected" value="">Beck's Green Lemon Sixpack 24x0.33l</option> <option value="">Beck's Ice 24x0.33l</option> <option value="">Beck's 24x0.33l</option> <option value="">Beck's Gold 24x0.33l</option> <option value="">Beck`s Green Lemon 24x0.33l</option> <option value="">Becks Red Ale 4-Pack 24x0.33l</option> </select> </td> </tr> <tr> <td>Beck's</td> <td>Ice</td> <td>24</td> <td>0.33</td> <td> <select name="data[61]" class="form-control" data-live-search="true" data-actions-box="true" title="Bitte wählen..."> <option value="">Bitte wählen...</option> <option value="">Becks Alkoholfrei 24x0.33l</option> <option value="">Becks Sixpack 24x0.33l</option> <option value="">Beck's Gold Sixpack 24x0.33l</option> <option value="">Beck's Green Lemon Sixpack 24x0.33l</option> <option selected="selected" value="">Beck's Ice 24x0.33l</option> <option value="">Beck's 24x0.33l</option> <option value="">Beck's Gold 24x0.33l</option> <option value="">Beck`s Green Lemon 24x0.33l</option> <option value="">Becks Red Ale 4-Pack 24x0.33l</option> </select> </td> </tr> <tr> <td colspan="5"><input class="btn btn-success" type="submit" name="save" value="Speichern"></td> </tr> </tbody> </table> <input type="hidden" name="shop_id" value="5"> </form>
The problem is that, although you provide the text to be displayed for the options, you don't provide the values of the options. 问题是,尽管您提供了要为选项显示的文本 ,但没有提供选项的值 。 The form is posted, but the values are simply empty because you set them to be empty. 表单已过帐,但是这些值只是空的,因为您将它们设置为空。
An example from MDN : 来自MDN的示例:
<!-- The second value will be selected initially -->
<select name="select">
<option value="value1">Value 1</option>
<option value="value2" selected>Value 2</option>
<option value="value3">Value 3</option>
</select>
To solve your problem, also fill the value=""
attributes with the corresponding option values. 要解决您的问题,请用相应的选项值填充value=""
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.