Pavils Jurjans wrote:
[snip]
In order to identify [the forms], I read their "name" property
(which sources from "name" HTML attribue). The problem is, that if the
form contains form control named "name", it overwrites the form name
property.
This can happen in any situation where the object model for a user
agent exposes elements via some kind of shortcut. Forms and images can
be referenced directly through the document object. Form controls
through a form object. Microsoft also think it a good idea to
reference elements using their id values through the global object.
In fact, I'm quite surprised that it's so easy to spoil any
of the form object properties
I personally think it's a mistake on the part of the browser vendors.
Note that none of this behaviour is standardised, but parts have
become a de facto standard.
[snip]
Is there any other alternative way to read and write the form object
properties, if their name conflicts with the form field names?
There are two solutions, but neither are necessarily what you're
looking for.
1) Don't use the name attribute to identify the form. That
mechanism was labeled a compatibility feature a long time
ago. For instance, XHTML Strict has removed the name attribute
from a number of elements, including FORM (but not form
controls). Instead, use the id attribute. Of course, you'll
still run foul of the problem if you have an 'id' control.
2) Change the capitalisation of the form control. ECMAScript is,
after all, case-sensitive.
If IE isn't a concern, which isn't likely, a third possible solution
which would require changes to neither your mark-up nor server-side
code is the use of the getAttribute method. However, I haven't tested
whether that's viable across a range of user agents (though it does
work in Firefox).
The reason why it doesn't work in IE (and Opera, since it tries to
emulate some of IE's object model) is that Microsoft decided to flout
the W3C DOM again and allow getAttribute to return anything (function
references to listeners, object references to elements, etc.) rather
than just the string values of attributes.
Good luck,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.