我正在追逐一个处理 HTML 表单的挑战,该表单的输入字段是使用包含多个选择字段的 JavaScript DOM 动态创建的。这是我拥有的表单的示例代码:
<input type="text" name="attributeIndex[]" id="brand" class="form-control" placeholder="brand">
<select name="attributeIndex[]" id="color" class="form-control">
<option value="92">Aero</option>
<option value="277">Aluminum</option>
<option value="91">Amber</option>
</select>
提交表单后,我想在 PHP 数组中获取表单数据,如下所示:
$formData=$_GET['attributeIndex'];
数组 $formData 应该是这样的:
array(
[0]=>text input value here
[1]=>array(list of selected colors here)
)
任何建议将不胜感激!