Reply to Re: Elements with the same name

Your name:

Reply:


Posted by Jukka K. Korpela on 02/07/06 22:05

"Jonathan N. Little" <lws4art@centralva.net> wrote:

>>> <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)
>
> Actually the answer is yes,

It depends on what you are trying to accomplish.

> the data will be in an array
>
> name[0].value has the first form elements value
> name[1].value has the second form elements value

No, the data will be sent as name=value items. How the server-side form
handler deals with them is its business. Before making any assumptions,
note that
a) it is unpredictable (browser-dependent) what happens if no choice
is made in a <select> element that has no initially selected options
b) data _should_ appear in the form data in the same order as the
elements appear in HTML source, but it is unwise to rely on this
and, besides, the server-side form handler might reorder the items.

Thus, in practical terms, you should use different names for <select>
elements (if you use them at all).

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

[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

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