由 Ajax 在表单中填充的选择的 POSTvalue


POSTvalue of a select populated by Ajax in a form

这可能是

一个非常典型的任务,但我已经发布了破解解决方案。

我正在使用一个包含 2 个选择选项的表单

<form enctype="multipart/form-data" id="uploadimage"  method="post" action="" class="allForms">
<select id="parentCatSel" onchange=listsubcategory(this.value)>
<option value="">Choose category</option>
</select>
<div id="subcatcontainer"><select id="subCatSel"><option value="">Choose Sub category</option></select></div>
<input name="save" class="save" type="submit"  id="save" value="Save"/>
</form>

根据在"parentCatSel"中选择的类别,"子类别容器"填充了子类别的选择选项对于所选父类别列表子类别()

返回

 <select id="subCatSel"><option value="">Choose Sub category</option>
<option value="1">1</option>
<option value="2">2</option></select>

子类别的显示工作正常,没有错误,但是当我尝试在表单中发布值时,我无法在"subCatSel"中检索所选选项的值,如下所示

    document.getelement['subCatSel']= null
post['subCatSel'] = null

请提出替代方案。

将名称属性添加到所选输入。

<select id="subCatSel" name="subCatSel"><option value="">Choose Sub category</option>

对不起,伙计们,我在实际代码中编码的糟糕之处。我错过了选择中的报价

只是将其更改为

它按预期工作!,谢谢大家