473,465 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

problem with <select multiple="true">

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
6 7696
*** 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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Arvid Andersson | last post by:
Hello, I need to convert a string to a number, but the string can contain +,-,* and / as well as parenthesis. For example, if I have the string "30/(6+9)" I would like a function that returned the...
4
by: matatu | last post by:
Hi to all, I have a xml file, a substring like: &lt;a href=&quot;#&quot;&gt;text&lt;/a&gt; which after an xslt trasform is rendered as (using xsl:output method html): &lt;a...
3
by: F. Da Costa | last post by:
Hi, Does the following indeed imply that this event is NOT called when an <input type="checkbox" is toggled? This would thus imply the usage of the onClick handler instead (assuming an action...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
2
by: trint | last post by:
With the following code, I get the "message" whether or not there is content in my filefield: function check_file_field() { var file_field = document.getElementById("custCartFile");...
1
Fary4u
by: Fary4u | last post by:
Hi Guys i'm trying to upload a file, i've tried 3 different methods but still not work out i don't know how to over come this problem hidden file value, multiple form or popup uploading. 1-...
1
by: Webstorm | last post by:
Hi, I hope someone can help me sort this out a bit, Im completely lost. Here is the page I am working on: http://www.knzbusinessbrokers.com/default.asp I have 3 search critera that I need to...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.