我有问题。我需要在一行或多行上重复选择选项。像这样:
表示我指定的输入字段
<td class="col-md-12"><input name="featureValue[]" value=""></td>
<td class="col-md-12"><input name="featureValue[]" value=""></td>
<td class="col-md-12"><input name="featureValue[]" value=""></td>
<td class="col-md-12"><input name="featureValue[]" value=""></td>
选择我使用的选项
<select name="listFeature[]" id="listFeature_1">
<option value="1" id="listFeature-0">Material Case </option>
<option value="2" id="listFeature-1">Thickness Case </option>
<option value="3" id="listFeature-2">Color Case</option>
<option value="4" id="featureList-4">Weight</option>
<option value="6" id="featureList-6">Models</option>
<option value="7" id="listFeature-7">Type Movement</option>
</select>
<select name="listFeature[]" id="listFeature_2" >
<option value="1" id="listFeature-0">Material Case </option>
<option value="2" id="listFeature-1">Thickness Case </option>
<option value="3" id="listFeature-2">Color Case</option>
<option value="4" id="featureList-4">Weight</option>
<option value="6" id="featureList-6">Models</option>
<option value="7" id="listFeature-7">Type Movement</option>
</select>
<select name="listFeature[]" id="listFeature_3" >
<option value="1" id="listFeature-0">Material Case </option>
<option value="2" id="listFeature-1">Thickness Case </option>
<option value="3" id="listFeature-2">Color Case</option>
<option value="4" id="featureList-4">Weight</option>
<option value="6" id="featureList-6">Models</option>
<option value="7" id="listFeature-7">Type Movement</option>
</select>
<select name="listFeature[]" id="listFeature_4" >
<option value="1" id="listFeature-0">Material Case </option>
<option value="2" id="listFeature-1">Thickness Case </option>
<option value="3" id="listFeature-2">Color Case</option>
<option value="4" id="featureList-4">Weight</option>
<option value="6" id="featureList-6">Models</option>
<option value="7" id="listFeature-7">Type Movement</option>
</select>
我需要处理一对select-option和value输入。 我有$ _POST [&#34; featureValue&#34;],其中包含一个包含这些值的数组
$_POST["featureValue"][0]="Auto mechanic"
$_POST["featureValue"][1]="Steel"
$_POST["featureValue"][2]="Sport"
$_POST["featureValue"][3]=""
但$ _Post [&#34; listFeature&#34;]仅包含最后一个值
$_POST["listFeature"][0]= 2
与值
相关联$_POST["featureValue"][3]=""
我需要
$_POST["listFeature"][0]= 7
$_POST["listFeature"][1]= 0
$_POST["listFeature"][2]= 6
$_POST["listFeature"][3]= 2
似乎select-option不能传递数组 有人能帮助我吗?
(用谷歌翻译翻译)
答案 0 :(得分:0)
我确认代码没问题。问题是,当您使用按钮添加功能创建新行时,将禁用上一个选择选项。这意味着您不会传递select-option禁用的值。 为了解决这个问题,我禁用了select选项的所有内部选项,只保留选中的选项。 然后我修改了代码
List = document.getElementById(“listFeature _”+ id); List.setAttribute('disabled','disabled');
var option = document.getElementById(“listFeature”)。getElementsByTagName(“option”); for(var i = 0; i&lt; op.length; i ++){ (选项[i]。选中)? option [i] .disabled = false:option [i] .disabled = true; }
现在它似乎是我的愿望