Reply to Re: Elements with the same name

Your name:

Reply:


Posted by Jonathan N. Little on 02/07/06 16:53

Stanch wrote:

> Not sure what you're trying to achieve (javascript issues?), but if
> it's of any help, you can do name[] and make it into an array.
>
> e.g. <select name="name[]"></select>
>
> Using name[] you can have multiple selects/inputs with the same form
> name.
>

Actually the brackets in the name is needed if the receiving script is PHP

<form_element name="some_name[]" ...

but not needed for Perl or JavaScript

<form_element name="some_name" ...

> However, of course it's best if you use distinct names to tell them
> apart.

Can be very usefully on a form that collects like data but the quantity
is unknown. Say for instance an order form {PHP example}

1st item
<input type="text" name="item[]">
<input type="text" name="price[]">
<input type="text" name="qty[]">
<input type="text" name="amount[]">

2nd item
<input type="text" name="item[]">
<input type="text" name="price[]">
<input type="text" name="qty[]">
<input type="text" name="amount[]">
....

nth item
<input type="text" name="item[]">
<input type="text" name="price[]">
<input type="text" name="qty[]">
<input type="text" name="amount[]">

count the elements in the array, iterate though them and build up an
order...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com

[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

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