Reply to Re: Elements with the same name

Your name:

Reply:


Posted by Harlan Messinger on 02/07/06 15:16

Leszek wrote:
> Hi.
>
> <div id="id1">
> <select name="name">
> //options
> </select>
> </div>
>
> <div id="id2">
> <select name="name">
> //options
> </select>
> </div>
>
> Is it ok to have two or more select lists with the same name? (Each in
> different div)

It's legal. If they're in two different forms, only the one that belongs
to the form being submitted will get sent back to the server anyway. If
they're in the same form, the question becomes: why are you doing this?

What will happen is that two name/value pairs will get sent to the server:

name={value of option selected from list 1}
name={value of option selected from list 2}

What the server will do with this is a different question. I saw someone
else refer to using "name[]". I've only glanced at PHP, but that sounds
familiar: it causes PHP to create an array out of the values, IIRC. In
ASP, though, you don't need the brackets: if more than one name/value
pair having the same name is received, ASP will treat it as an array.

> Is is possible to check which value from which select was chosen?
> For example using php $_POST
> or there will be just one value remembered because all select list have the
> same name?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация