dqk77945 2014-04-25 13: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 13:55
    关注

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

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

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?