dqk77945 2014-04-25 05:19
浏览 31
已采纳

提交表单后,为什么select控件中已检查元素的值不会出现在$ _POST数组中? [重复]

This question already has an answer here:

I've following HTML code:

<form action="rebates.php" role="form" method="post">
<select id="example28" multiple="multiple" name="applicable_states">
    <option value=""  selected='selected'>Select Unit</option>
    <option value="1" >Alabama</option>
    <option value="2" >Alaska</option>
    <option value="3" >Arizona</option>
    <option value="4" >Arkansas</option>
    <option value="5" >California</option>
 </select>
<button type="submit" class="btn btn-primary">Preview</button>
</form>

The JQuery code for select control is as follows:

/*jQuery Code*/
 $(document).ready(function() {
    window.prettyPrint() && prettyPrint();
     $('#example28').multiselect({
         includeSelectAllOption: true,
         maxHeight: 150
     });
 });

I've used Bootstrap's js and css (Multiselect and Prettify) to achieve this. My issue is I'm not getting the checked elements' values after submission of form in $_POST array oe rebates.php. Can someone please help me in this regard? Thanks in advance. When I check some values from the select control and submit the form I'm getting the $_POST array as follows:

Array
(
 [applicable_states] => 11
 [multiselect] => 11
)

Why this is happening? The code in rebates.php is as follows:

<?php
print_r($_POST); die;
?>
</div>

展开全部

  • 写回答

1条回答 默认 最新

  • dppb79372 2014-04-25 05:55
    关注

    PHP needs to know it's an array. So you need to change the name of the select.

    name="applicable_states[]"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部