问题的下拉列表称为subCategory, 通过选择其onchange事件触发ajax请求的另一个下拉类别来填充它的内容。
问题在于即使子类别的内容按预期填充(可见),我也可以看到它们并在子类别下拉列表中选择它们,当我执行php帖子时,我只能得到初始选项的值{ {1}}无论我选择任何其他元素。
也许dom没有刷新但我不确定..
提交后直接<option value="subCategory1">Select a subcategory</option>
的PHP print_r
$_REQUEST
HTML(已编辑)
Array ( [act] => additem [category] => 200381 [subCategory] => subCategory )
PAGE SOURCE:
<form id="additemform" action="add-item.php?act=additem" method="post" enctype='multipart/form-data'>
<div id="section-category">
<select id="category" class="category" name="category">
<option value="category1">Select a category</option>
{html_options values=$cat_id_array options=$cat_names_array selected=$smarty.session.additem_category}
</select>
<p class="test" id="boxCity">
<select id="subCategory" class="subCategory" name="subCategory">
<option value="subCategory1">Select a subcategory</option>
{html_options options=$smarty.session.subcategories selected=$smarty.session.additem_subcategory}
</select>
</p>
</div>
<!--/#section-category-->
<div class="bottom-area">
<input id="submit-addItem" type="button" value="Add my item" />
</div>
</form>
JQUERY
<div id="section-category">
<select id="category" class="category" name="category">
<option value="category1">Select a category</option>
<option value="200381" selected="selected">Antiques</option>
<option value="200841" >Other cat</option>
</select>
<p class="test" id="boxCity">
<select id="subCategory" class="subCategory" name="subCategory">
<option value="subCategory1">Select a subcategory</option>
<option value="23430118">Digital Art</option>
<option value="6643435">Photographic Images</option>
</select>
</p>
</div><!--/#section-category-->
答案 0 :(得分:0)
这不起作用的原因是我有另一个选择框(向下)具有相同的名称和第一个选项作为子类别,PHP正在使用此值。
现在可以了,谢谢