Prev: How to rotate the image
Next: javascript:false
From: VK on 9 Jan 2006 15:02 Frances wrote: > is it document.getElementByName or document.getElementsByName? That was well explained to others but there is always something to add :-) getElementsByName in IE (Internet Explorer) grabs all elements *with such id or with such name* - it doesn't give a damn of difference. It is not standard but fair spelled in the method description on MSDN. Also it is W3C (and common sense) requirement that id's and names must be unique for each element on one page. So the presence of getElementsByName method by itself is a mistery. I think that someone in W3C was just starting to learn HTML while writing the relevant standards for it (it happens). Do not confuse it with getElementsByTagName - here "elements" are plural because on the same page can be any amount of <p>, <div> and so elements..
From: Michael Winter on 9 Jan 2006 15:34 On 09/01/2006 20:02, VK wrote: [snip] > Also it is W3C (and common sense) requirement that id's and names must > be unique for each element on one page. An id attribute value must be unique within a document, however, this is not true for all name attributes. The name attributes that are, on the whole, backwards-compatible identifiers (A, APPLET, FORM, FRAME, IFRAME, IMG, MAP) should be unique. Form controls (BUTTON, INPUT, OBJECT, SELECT, TEXTAREA) can, and in some cases (radio buttons and checkboxes) must, be duplicates. The remaining elements (META, PARAM) are not so well-defined as their use tends to fall outside the scope of HTML. [snip] Mike -- Michael Winter Prefix subject with [News] before replying by e-mail.
From: RobG on 9 Jan 2006 15:40 VK wrote: > Frances wrote: > >>is it document.getElementByName or document.getElementsByName? > > > That was well explained to others but there is always something to add > :-) > > getElementsByName in IE (Internet Explorer) grabs all elements *with > such id or with such name* - it doesn't give a damn of difference. It > is not standard but fair spelled in the method description on MSDN. > > Also it is W3C (and common sense) requirement that id's and names must > be unique for each element on one page. That is a requirement of IDs but not for all elements that can have a name - e.g. radio buttons. [...] > I think ... .... you didn't check the specification: <URL:http://www.w3.org/TR/html4/index/attributes.html> [...] -- Rob
From: Thomas 'PointedEars' Lahn on 9 Jan 2006 16:13 Michael Winter wrote: > On 09/01/2006 20:02, VK wrote: >> Also it is W3C (and common sense) requirement that id's and names must >> be unique for each element on one page. > > An id attribute value must be unique within a document, however, this is > not true for all name attributes. True. > The name attributes that are, on the whole, backwards-compatible > identifiers (A, APPLET, FORM, FRAME, IFRAME, IMG, MAP) should be unique. How did you get that idea? PointedEars
From: CK on 9 Jan 2006 16:18
Definitely getElementsByName... It returns an array of elements with that name attribute. Then you can access individual values by looping through the array. aFields = document.getElementsByName('test'); for (x = 0; aFields.length; x++) { alert(aFields[x].value); } hope this helps. Chris "Frances" <fdr58(a)yahoo.com> wrote in message news:43c283ae$1_1(a)x-privat.org... > is it document.getElementByName or document.getElementsByName? > ^ > > reason I ask is that I have to change ref's in my code from document.all > to sthg that works also in FF... so changed something like this > > docslide = document.all['slide']; > docslide = document.getElementByName("slide"); > > but then looked in Danny G's DOM ref > (http://www.dannyg.com/dl/JSB5RefBooklet.pdf) > > and there's a "s" after "Element" > > if I search in google for document.getElementsByName with or w/o that "s" > I find entries for both.. pls, which one is it? b/c neither one is > working for me.. thanks.. > > Frances > |