RE: [PHP] php and javascript
| From: | Jared Williams | Date: | Mon, 11 Apr 2005 23:23:17 +0000 |
| Subject: | RE: [PHP] php and javascript | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-212863@lists.php.net to get a copy of this message | ||
> On Sun, April 10, 2005 4:32 pm, Marek Kilimajer said:
> > Assuming your form is named "Selection", you will have a javascript
> > array document.forms['Selection'].elements['distID[]']
> available. You
> > can try:
> >
> > alert(document.forms['Selection'].elements['distID[]'][0].value);
>
> I can GUARANTEE this will *NOT* work.
>
> You *CANNOT* use [] as part of a 'name' in JavaScript.
>
> No way, no how.
>
> No matter how you quote it, embed it in a string, or try to
> sneak up on it.
>
> It ain't gonna work.
>
> 'Cuz I tried every godamn reasonable (and quite a few
> UN-resaonable) ways to do that. *
>
Hmm, document.forms['Selection'].elements['distID[]'][0].value is perfectly
valid, and should work in any decent browser.
There is also document.getElementsByName()
Jared