By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,657 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

problem with <select multiple="true">

P: n/a
Hi,

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? I would be very appreciative for any
help. Thank you in anticipation.

Regards

Rolf Wester

----------------

part of the form element:

echo "<select size=5 name=\"channels\" multiple=\"true\">";
echo "<option> CH1 </option>";
echo "<option> CH2 </option>";
echo "<option> CH3 </option>";
echo "<option> CH4 </option>";
echo "<option> CH5 </option>";
echo "</select>";

Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
*** Rolf Wester wrote/escribió (Wed, 21 Jan 2004 12:42:03 +0100):
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?


The easiest way is to make channels become an array:

<select name="channels[]"></select>
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #2

P: n/a
Rolf Wester <we****@ilt.fraunhofer.de> 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? I would be very appreciative for any
help. Thank you in anticipation.

Regards

Rolf Wester

----------------

part of the form element:

echo "<select size=5 name=\"channels\" multiple=\"true\">";


echo "<select size=5 name=\"channels[]\" multiple=\"true\">";

Makes $channels an array.

HTH;
JOn
Jul 17 '05 #3

P: n/a
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.

--
Jock
Jul 17 '05 #4

P: n/a
Rolf Wester wrote:
Hi,

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? I would be very appreciative for any
help. Thank you in anticipation.

Regards

Rolf Wester

----------------

part of the form element:

echo "<select size=5 name=\"channels\" multiple=\"true\">";
echo "<option> CH1 </option>";
echo "<option> CH2 </option>";
echo "<option> CH3 </option>";
echo "<option> CH4 </option>";
echo "<option> CH5 </option>";
echo "</select>";

Thank you all very much for the help.

Rolf Wester
Jul 17 '05 #5

P: n/a
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
Jul 17 '05 #6

P: n/a
Agelmar wrote:
[...] XHTML, which is the preferred standard.
Preferred by whom? Impetuous duhzyners? It's gotta be the X, it sends
them crazy! HTML just lacks that certain X-factor, doesn't it?

:-]

http://www.hixie.ch/advocacy/xhtml

(BTW, XHTML1.0 isn't a standard; the W3C isn't -- and can't be -- a
standards body, the far-reaching misconception notwithstanding.)
[The HTML4.01 specification] was written when Netscape 4.x was still
the primary browser to develop for.


Ah, are we talking at cross-purposes here? My comments concern
authoring for the WWW, not severely restricted intranets.

--
Jock
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.