On Mar 8, 11:55 am, Man-wai Chang <toylet.toy...@gmail.comwrote:
What's the difference between name and id?
Why 2 reference points?
name is coming from the initial DOM 0 (DOM Zero Level) interface
model. In this model form controls are identified by name or by index
in elements collection:
document.forms[0].elements[0];
document.forms[0].elements["FirstControl"];
Only controls having name attribute set are being submitted, this rule
is in effect since then and forever.
id attribute was introduced only in DOM 1. As other poster pointed out
ID supposed to be unique for the given document, while name can be the
same for many elements (think of radio buttons group for instance).
This is why say accesskey is attached to ID and not to name. That is
not the only neither the main reason but it gives the idea why
sometimes it is useful to set both id and name for a form control,
like:
<input type="radio" value="yes" name="rdg" id="rd01">
<label for="rd01">Yes</label>
<input type="radio" value="no" name="rdg" id="rd02">
<label for="rd02">No</label>
For anchors and links collections name attribute usage is deprecated
and rarely used.
document.images["ImageName"] is still pretty much in use.
Both from above are from the same DOM 0 model.
P.S.
Website:http://www.itech.com.hk(IE only)
Do you have a Gecko-only version to look at?