HTML Mutli选择不发布值返回到PHP [英] HTML Mutli Select Not Posting Values Back to PHP

查看:86
本文介绍了HTML Mutli选择不发布值返回到PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < select multiple = 

我有一个html格式的选择框, 'multiple'name ='mydropdown'>
< option value ='1'> 1< / option>
< option value ='2'> 2< / option>
< option value ='3'> 3< / option>
< / select>

在PHP中,如果我看看 $ _ REQUEST 它会在选择框中为最后选定的值返回单个值。



为了获得数组或列表,需要更改或编辑什么?选择的项目发回来,以便我可以在PHP中处理结果?



我想将select转换为 JQuery multi select box,所以如果你的答案可以应用于JQuery选择框并且我将不胜感激。PHP解决方案

PHP需要表单控件名称以 [] 结尾,如果您从相同名称获得多个值。

 < select multiple ='multiple'name ='mydropdown []'> 

获取多个值的原因是多个表单控件具有相同的名称,或者单个选择多个元素。


I have a select box in a html form that does not post values back to php.

<select multiple='multiple' name='mydropdown'>
    <option value='1'>1</option>
    <option value='2'>2</option>
    <option value='3'>3</option>
</select>

in PHP if I have a look at the $_REQUEST it returns a single value for the LAST selected value in the select box.

What do I need to change or edit in order to get a array or list of selected items posted back so that I can handle the result in PHP?

I would like to transform the select into a JQuery multi select box so if your answer could apply to JQuery select boxes aswell I would appreciate it

解决方案

PHP requires that form control names end in [] if you are getting multiple values from the same name.

<select multiple='multiple' name='mydropdown[]'>

It doesn't matter if the reason for getting multiple values is multiple form controls with the same name, or a single select multiple element.

这篇关于HTML Mutli选择不发布值返回到PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆