$_POST and multiselectable password:   :: lost password

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

  •   Subject
  • Author
  • Posted on

If I put in the code the tag <select> that can be multiselectable (a listbox  
where I can select more that one item), how can I know what are the selected  

example, try this in a .php file (note the multiple="multiple" attribute):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">
<title>Test page</title>

 echo("Selected:" . $_POST["List"]);

 <form id="Form" action="<?php echo(basename(__FILE__)) ?>" method="post">
 <select name="List" size="3" multiple="multiple">
        <option value='i1'>Item 1</option>
        <option value='i2'>Item 2</option>
     <option value='i3'>Item 3</option>
 <input type="submit" />

If you select more that one item and press the submit button $_POST says the  
first item selected... but the oters???
How can I know all the selected items???


Re: $_POST and multiselectable tag

ELINTPimp wrote:

Quoted text here. Click to load it

Ok, I thank you to let me lost time searching for this *complex* solution  
(ah, select+multiple, not select+array) that is


and not


Good, this works... also if the "[]" is not valid in html4 name attribute :)


ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed  
by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),  
colons (":"), and periods (".").

Re: $_POST and multiselectable tag

ELINTPimp wrote:

Quoted text here. Click to load it

nor utility.

I'm programming and living NGs since 10 years: if I asked something that's  
because I didn't find clear/secure asnswers on the web.

Thanks again for reply to me the same way as you replyed to other people in  
the NG this day.  

Re: $_POST and multiselectable tag

Quoted text here. Click to load it

 It is valid.

Quoted text here. Click to load it

 The name attribute is not of type NAME, see the DTD (and previous


Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Re: $_POST and multiselectable tag

Fabio wrote:
Quoted text here. Click to load it

If that were the case, it wouldn't work, would it?  But it does.  On  
every server, with every version of PHP, with every browser...

It does because you're looking at the wrong stuff.  As Andy said, the  
name attribute is not of type NAME.  Look at the DTD.

Argue all you want.  ELINTPimp and Andy gave you the correct answer.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: $_POST and multiselectable