我有一个下拉列表,其中用户选择一些值并通过javascript按排序顺序移动到其他下拉列表。如何将下一页的第二个下拉列表中的选定值转换为PHP变量?
<form name="Example" action="next.php" method="post">
<table border="0" cellpadding="3" cellspacing="0">
<tr>
<td>
<select name="Features" size="9" MULTIPLE>
<option value="2">Row 2</option>
<option value="4">Row 4</option>
<option value="5">Row 5</option>
<option value="6">Row 6</option>
<option value="7">Row 7</option>
<option value="8">Row 8</option>
<option value="9">Row 9</option>
</select>
</td>
<td align="center" valign="middle">
<input type="Button" value=">>" style="width:100px" onClick="SelectMoveRows(document.Example.Features,document.Example.FeatureCodes)">
<br>
<input type="Button" value="<<" style="width:100px" onClick="SelectMoveRows(document.Example.FeatureCodes,document.Example.Features)"><br>
<input type="Button" value=">>>>" style="width:100px" onClick="selectAll(document.Example.Features);SelectMoveRows(document.Example.Features,document.Example.FeatureCodes)"><br>
<input type="Button" value="<<<<" style="width:100px" onClick="selectAll(document.Example.FeatureCodes);SelectMoveRows(document.Example.FeatureCodes,document.Example.Features)">
</td>
<td>
<select name="FeatureCodes[]" id="FeatureCodes" size="9" MULTIPLE>
<option value="1">Row 1</option>
<option value="3">Row 3</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit" value="submit" id="submit" name="submit"></td>
</tr>
</table>
提前致谢!!
答案 0 :(得分:1)
第二个表单字段中所选元素的值应为:
$_POST['FeatureCodes'][0];
如果您在页面上只有一个FeatureCodes
表单,则可以从HTML中删除[]
并使用$_POST['FeatureCodes'];