Edit report at https://bugs.php.net/bug.php?id=4110&edit=1
ID: 4110 Comment by: jmichae3 at yahoo dot com Reported by: fuf at fuf dot sh dot cvut dot cz Summary: getting arrays from a form Status: Closed Type: Bug Package: Other Operating System: linux-2.2.x PHP Version: 3.0.13 Block user comment: N Private report: N New Comment: Michal - try putting a space in name="n_sas"size=10 Previous Comments: ------------------------------------------------------------------------ [2000-04-11 18:28:01] rasmus at cvs dot php dot net This is a FAQ - use the form elements numerical index instead of the full element name from Javascript. ------------------------------------------------------------------------ [2000-04-11 17:57:44] fuf at fuf dot sh dot cvut dot cz hello php developers! i've come across a rather debatable behaviour of PHP getting array variables from a form. let's have a html form with multiple selection list: form.html: <html> <body> <form name='aform' method="post" action="process_form.php3"> <select name="n_sas"size=10 MULTIPLE> <option value=1>option 1</option> <option value=2>option 2</option> <option value=3>etc.</option> </select> </form> </body> </html> the php3 file could then be: process_form.php3: <? echo "number of elements in n_sas is " . count($n_sas) . "<br>\n"; ?> this will print 1 ($n_sas is not an array according to php). okay, so i change the name of the variable in the form.html file to 'n_sas[]': ... <select name="n_sas[]" size=5 MULTIPLE> ... in this case php will consider $n_sas as an array and all its items will be accessible. all is fine, BUT: 'document.aform.n_sas[]' is NOT accessible from javascript! if the name is 'n_sas', obviously the selection list is accessible from the javascript (via document.aform.n_sas) but PHP won't make it an array and the variable $n_sas will have the value of the last selected option. IMO, that's not a correct behaviour. thanks for your time, Michal ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=4110&edit=1