note 19871 deleted from language.types.array by curt
| From: | curt@php.net | Date: | Tue, 06 Jul 2004 02:12:33 +0000 |
| Subject: | note 19871 deleted from language.types.array by curt | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72643@lists.php.net to get a copy of this message | ||
Note Submitter: paul_williams@dstoutput.com
----
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).