我有一个普通的HTML表单,通过POST提交。提交工作并将数据发送到接收者页面。令我困惑的是,保存按钮和隐藏输入(shop_id)是从下拉列表中发送的,而不是选定的选项。
选项位于帖子中,但值为空。帖子看起来像这样:
save:Speichern
data[58]:
data[60]:
data[61]:
shop_id:5
有谁知道这会怎么样?
<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>
&#13;
答案 0 :(得分:1)
问题在于,虽然您提供了为选项显示的文字,但您未提供选项的值。表单已过帐,但值只是空的,因为您将它们设置为空。
来自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>
要解决您的问题,请使用相应的选项值填充value=""
属性。