문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top