John Dunlop wrote:
Rolf Wester wrote:
I have a form with a select element with multiple="true". When using
the GET method (I suppose the same happens with the POST method) I
can seen that the form sends channels=CH1&channels=CH2 when CH1 and
CH2 have been choosen. $_GET["channels"] gives me "CH2". Is there
any way to get all the choosen channels elements?
You've been shown the solution, viz., change your select element's
name to end in "[]". This is actually a FAQ.
http://www.php.net/manual/en/faq.htm...elect-multiple
In HTML, the multiple attribute doesn't take the value "true", nor
does it take the value "yes", as PHP.net's FAQ creator would have you
misbelieve. If any of those values are used, it's only by dint of
browsers' error-recovery that users are able to select multiple
options at all. The multiple attribute either takes the value
"multiple", or it can exist in minimised form: only the attribute
value "multiple" is left, i.e.,
<select multiple>
The latter is preferred, according to HTML4.01, sec. B.3.4.
Actually, the former is preferred (<select multiple="multiple"...>)
Attribute minimization is actually forbidden in XHTML, which is the
preferred standard. And just FYI, what you're quoting (the HTML 4.01
Specification) was developed in from 1997-1999 and finally approved in 1999.
This was written when Netscape 4.x was still the primary browser to develop
for. Now, we consider anyone using Netscape 4.x to be a hopeless cause. All
browsers today* (all meaning >99%) support the non-minimized form.
See:
http://www.w3.org/TR/xhtml1/#diffs
*Data taken from the W3C, showing that in July 03, 59% were using IE6, 34%
using IE5, 1% using IE4 (all of which supported the non-minimized form) and
only 1% using Netscape 4x. These numbers have likely changed greatly in the
past five months, with the rise of Mozilla and Firebird, and of course the
ever increasing popularity of IE6... I would put the number of users of
Netscape 4.x at well below 1% today. See:
http://www.w3schools.com/browsers/browsers_stats.asp