[thelist] Problem accessing for values with []

Jonathan Dillon jdillon at boehm-ritter.com
Thu Feb 10 17:36:16 CST 2005

> >I'm on to my second odd problem!  I've got a javascript file
> that needs
> >to make reference to the following form: 
> >document.myform.form[fieldname].value
> >
> >But:
> >alert('val: ' + document.main.form[journal].value);

> Should that not be:
>alert('val: ' + document.main.form['journal'].value);

Thanks to Chris and everyone else for the replies.  I guess I should have
been more clear.  form[fieldname] wasn't an attempt to access a form
element, but it's actual name="" element of the form (the whole thing,
including the form[]).  Sometimes, don't you just WISH you posted the html

I was actually able to solve it with:

This escapes it as a literal value and seems to work ok.  Using Christian's
technique, just for the archive's sake:


Would be


Looks weird.

Thanks again!


More information about the thelist mailing list