note 19871 added to language.types.array
| From: | paul_williams at dstoutput dot com | Date: | Wed, 13 Mar 2002 19:57:26 +0000 |
| Subject: | note 19871 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27751@lists.php.net to get a copy of this message | ||
My trick for using array input fields with javascript and PHP follows
<select size=6 name="MyArray" multiple>
<option>foo</option>
<option>bar</option>
<option>baz</option>
</select>
This allows you to access the list control in JavaScript by document.formname.MyArray. When
it's time to submit, have an onClick (or onSubmit) handler to do the following:
document.formname.MyArray.name="MyArray[]";
Works great, and satisfies the Principle of Least Astonishment (as much as can be under these
conditions IMHO).
--
http://www.php.net/manual/en/language.types.array.php
http://master.php.net/manage/user-notes.php?action=edit+19871
http://master.php.net/manage/user-notes.php?action=delete+19871
http://master.php.net/manage/user-notes.php?action=reject+19871