Re: field names with square brackets
| From: | Matte Edens | Date: | Wed, 08 Jun 2005 17:30:03 +0000 |
| Subject: | Re: field names with square brackets | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-19538@lists.php.net to get a copy of this message | ||
Use an "id" attribute on the select. Then getElementById() in your JS.
matte - matte@arubanetworks.com
webmonkey » arubanetworks.com
Ed Greenberg wrote:
HTML_QuickForm seems to be taking my fieldnames and adding a pair of square brackets on the end. Thus $this->addElement('select','counties','Counties:',$allcounties,array('size'=>10,'multiple')); results in <select size="10" multiple="multiple" name="counties[]"> <option value="1">Hampden County, MA</option> <option value="2">Hampshire County, MA</option> ---snip--- <option value="15">Grafton County, NH</option> <option value="16">Coos County, NH</option> </select> The problem with this is that you can't direct Javascript at document.formname.counties[] or even at document.formname.counties\[\] I'm imagining that the [] is a form of communication from the rendering part of quickform to the receiving part, probably indicating that multiple values are possible. Has anybody worked around the problem of applying javascript to these elements? We'd like a "clear" button to deselect everything in the select box. Justin? Any ideas? Thanks, </edg>