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

Patrick Bierans pbierans at lynet.de
Tue Sep 18 06:20:56 CDT 2001


"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



More information about the Javascript mailing list