For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > June 2005 > Re: [PEAR] field names with square brackets









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] field names with square brackets
Matte Edens

2005-06-08, 3:58 pm

Use an "id" attribute on the select. Then getElementById() in your JS.

matte - matte@arubanetworks.com
webmonkey =BB arubanetworks.com


Ed Greenberg wrote:

>HTML_QuickForm seems to be taking my fieldnames and adding a pair of squ=

are=20
>brackets on the end. Thus
>
>$this-> addElement('select','counties','Counties
:',$allcounties,array('si=

ze'=3D>10,'multiple'));
>
>results in
>
><select size=3D"10" multiple=3D"multiple" name=3D"counties[]">
> <option value=3D"1">Hampden County, MA</option>
> <option value=3D"2">Hampshire County, MA</option>
>---snip---
> <option value=3D"15">Grafton County, NH</option>
> <option value=3D"16">Coos County, NH</option>
></select>
>
>The problem with this is that you can't direct Javascript at=20
>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 multip=

le=20
>values are possible.
>
>Has anybody worked around the problem of applying javascript to these=20
>elements? We'd like a "clear" button to deselect everything in the selec=

t=20
>box.
>
>Justin? Any ideas?
>
>Thanks,
></edg>
>
> =20
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com