From: Frances on
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

From: Michael Winter on
On 09/01/2006 15:39, Frances wrote:

> is it document.getElementByName or document.getElementsByName?

The latter. The method returns a collection so its name uses a plural form.

[snip]

> but then looked in Danny G's DOM ref

Based on the testament of other regulars in this group, Danny Goodman is
not a trusted source of scripting information. I've only read one
article written by him (an e-mail), and its content would have me draw
the same conclusion.

[snip]

> [N]either one is working for me.. thanks..

Link?

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
From: Martin Honnen on


Frances wrote:

> is it document.getElementByName or document.getElementsByName?

The specification is here
<http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259>
the specified method name is 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'];

If you have e.g.
<div id="slide">
with a unique id then you might be better off to use
document.getElementById('slide')

--

Martin Honnen
http://JavaScript.FAQTs.com/
From: Thomas 'PointedEars' Lahn on
Frances wrote:

> is it document.getElementByName or document.getElementsByName?

The latter one, where the name is because the method returns a collection
of element object references, not one element object reference.
^
> 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");

Use IDs and document.getElementById(...) instead. Unless you do not want
to support IE 4 users anymore, you should not replace document.all[...] with
the latter but implement it as an alternative if the feature-test for the
latter failed.

<URL:http://pointedears.de/scripts/test/whatami>
<URL:http://jibbering.com/faq/#FAQ4_26>

> but then looked in Danny G's DOM ref
> (http://www.dannyg.com/dl/JSB5RefBooklet.pdf)

That is not a good book, as there are few good books about the subjects
discussed here out there, if any.

<URL:http://jibbering.com/faq/#FAQ3_1>

As for me, Flanagan's book is old enough and revealed too many errors
here, that I cannot recommend it either.

> 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.

Yes, there are many incompetent people out there which is why the number
of Google hits does not qualify as proof for existence of a name.

> pls, which one is it? b/c

"w/o" == "without"?
"b/c" == "because"?

Do not assume that other people understand these abbreviations.

> neither one is working for me.. [...]

<URL:http://jibbering.com/faq/#FAQ4_43>
<URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259>
<URL:http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-getElBId>


PointedEars
From: web.dev on

Frances wrote:
> is it document.getElementByName or document.getElementsByName?

As mentioned by many others, it is document.getElementsByName.

> docslide = document.getElementByName("slide");

It doesn't work as you expected because this method looks for HTML
elements with the name 'slide', not elements with an attribute value of
'slide'. Thus, you should use a different method, for example:

docslide = document.getElementById("slide");

where you have:

<div id = "slide">...</div>

 |  Next  |  Last
Pages: 1 2 3 4 5
Prev: How to rotate the image
Next: javascript:false