Can anyone fix my bad Javascript?
November 25, 2006 4:22 PM
Subscribe
I have to set the content of a field using Javascript, but the field's name has a dot in it, making Javascript treat it like a delimiter. Maybe I'm just tired. Help me escape?
I seem to have left my books at home and I'm in an airport trying to fix something. I have to set the values (contents) of some fields that have names containing dots. This makes Javascript unhappy.
But this produces the expected "document.editForm.class2 has no properties" error. I have tried XML-style escaping the dot that matters, and also using square bracket style notation...
But then I get "missing name after . operator" (Javascript doesnt like the dot before 'value', apparently.)
I think I'm out of things to try, and my Googling leads me to examples like the above that allegedly work. I'm stuck using the field-names with dots, because it's feeding an app I can't control. If I remove the dots and name the field "arbitraryFieldName", it all works, so the dot is definitely the problem.
Can anyone see what I'm missing? I'm prepared to feel dumb. :)
posted by rokusan to computers & internet (8 comments total)
{input type="text" name="class2.repliedDate" value="11/01/06"}
{input type="button" value="TEST" onClick="document.editForm.[class2.repliedDate].value = '11/25/06'"}
With regular angle-brackets instead of curlies.
posted by rokusan at 4:25 PM on November 25, 2006