[Javascript] access form.element by name containing [ ]

Carl Adler carl at carladler.org
Tue Sep 18 05:33:47 CDT 2001


Possibly you should use escape and unescape
action%5Bnew%5D
might be worth looking at.
Carl

> From:  "Patrick Bierans" <pbierans at lynet.de>
> Reply-To: javascript at LaTech.edu
> Date: Tue, 18 Sep 2001 12:20:56 +0100
> To:  javascript at LaTech.edu
> Subject: [Javascript] access form.element by name containing [ ]
> 
> "access form.element by name containing [ ]"
> 
> Hello out there.
> 
> I use checkboxes named "action[new]", "action[del]" and
> "action[upd]". I have to do it this way because it produces
> arrays in PHP making it much (!) easier for me, and I cannot
> change it.
> 
> Now I want to access the object in JavaScript by the name
> of the checkbox. I cannot use the construct 'elements[2]'
> because the position varies.
> 
> I tried theese:
> document.forms[0].action[new].click();
> document.forms[0].action\[new\].click();
> document.forms[0].action['new'].click();
> document.forms[0].'action[new]'.click();
> document.forms[0].'action\[new\]'.click();
> 
> Must I check the name of each element to get the object?
> "for each $this as element if $this.name = 'action[new]' $this.click;"
> 
> Isn't there another way?
> 
> TIA,
> Patrick Bierans
> 
> P. Bierans
> 
> -- 
> Patrick Bierans - LYNET Kommunikation AG - http://www.lynet.de
> Das Internet-Systemhaus fuer Multimedia- und Netzwerkloesungen
> Zentrale Luebeck      Fon +49-451-6131-0, Fax +49-451-6131-333
> Niederlassung Hamburg Fon +49-40-65738-0, Fax +49-40-65738-333
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list