note 29659 rejected from language.variables.predefined by victor
| From: | victor@php.net | Date: | Thu, 20 Feb 2003 20:03:30 +0000 |
| Subject: | note 29659 rejected from language.variables.predefined by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-44271@lists.php.net to get a copy of this message | ||
This is in addition to pschulten at NOSPMweb dot de and slandau at miticom dot com.
If you need to access $_POST variables where the form element names were duplicated such as
<input type='text' name='my_field'>
<input type='text' name='my_field'>
<input type='text' name='my_field'>
you do need to rename to
<input type='text' name='my_field[]'>
<input type='text' name='my_field[]'>
<input type='text' name='my_field[]'>
when you do that, you can access them like this
$_POST[my_field][0]
$_POST[my_field][1]
$_POST[my_field][2]
however, and if you know a way around this please help,
you can no longer process these form elements as an array using JavaScript
For example:
for(var i = 0; i < 3; i++)
{
document.form_name.my_field[i].value = 'whatever';
}
you will get an error saying
document.form_name.my_field has no properties
or at least I got that error
Any suggestions?