bottom line:
- Form elements must have a name if you want them to be submitted
- Use id only if you need to refer to an element by getElementById
- Many programmers put the same name and ID on form elements
When Netscape created JavaScript, they used "name" to identify
elements. MS built IE to copy Netscape, so also supported "name".
However, the HTML spec decided to use id to identify elements but keep
name for backwards compatibility. Name still applies to form elements
and lots of others (e.g. name is mandatory on PARAM elements). MS seem
to hate ever removing functionality, so they continue to support name
as if it was ID.
Many programmers put the same name and ID on form elements. This isn't
required, but may be helpful if you intend to reference the element
using both the forms.elements collection and getElementById.
Name
"When a form is submitted for processing, some controls have
their name paired with their current value and these pairs
are submitted with the form. Those controls for which
name/value pairs are submitted are called successful
controls."
No comments:
Post a Comment