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 20 331020
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.
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/
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
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>
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..
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.
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
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
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" <fd***@yahoo.com> wrote in message
news:43**********@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
On 09/01/2006 21:13, Thomas 'PointedEars' Lahn wrote: Michael Winter wrote:
[snip] 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?
I recall a similar discussion last year.
Subject: firefox and innerHTML
Message-ID: <ew******************@text.news.blueyonder.co.uk >
Date: 2005-07-12 16:49:14 GMT
Though browsers can cope with duplicated attribute values, it is my
opinion that the /intent/ was for them to be unique.
As I mention in the cited post, the addition of these name attribute was
a revision to HTML 4.0 (which introduced the id attribute). Netscape,
which first designed and implemented several of the listed elements
before HTML 4.0, and did not support the id attribute, presumably
adopted the name attribute as an identifier due to the precedent set by
links (that is, A elements).
As I also note in that post, the collection nature of DOM 0 does not
extend to FORM elements. In a quick test in Fx 1.5 (because it was
running), it doesn't cover APPLET, A (obviously), IMG, or IFRAME
elements, either (I didn't test FRAME and MAP elements). If duplication
was expected, why would scripting mechanisms not have been written to cope?
Mike
--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Lee wrote: Where did you get the idea that names must be unique? Have you never used checkboxes?
You meant to say "radio button" of course. Yes, radio button *group* is
one, and what's going to be two?
It is nice from W3C to provide a whole separate method for a single
case instance, but should it be added then to form or radio object
itself instead?
The only other occasion I may think of (with my humble mind of course)
is that ugly "improvement" of PHP where elements named like "name[]"
will be automatically glued together into array on the server side. I
call this ugly because one should never break long time commonly
accepted standards to implement your own freshly invented ones.
Plus it gives a terrible school to newcomers. If you look at this group
archives like 2-3 years ago it will be full of questions like: how to
access form element named "foo[]" - document.forms[0].foo[] doesn't
work! and similar... Plus a reasonnable question after such "practice"
is: why the hell id's should be any different? - thanks to PHP.
Thinking back document.getElementsByName may be a W3C "endorsment"
towards PHP (? pure speculation).
VK wrote: You meant to say "radio button" of course. Yes, radio button *group* is one, and what's going to be two? It is nice from W3C to provide a whole separate method for a single case instance, but should it be added then to form or radio object itself instead?
I often use forms with multiple <input> tags with the same name.
Radio buttons are not a special case, it's just a common example of the
general case.
Multiple inputs with the same name (even of different types!) has been
supported forever.
The only other occasion I may think of (with my humble mind of course) is that ugly "improvement" of PHP where elements named like "name[]" will be automatically glued together into array on the server side. I call this ugly because one should never break long time commonly accepted standards to implement your own freshly invented ones.
Which standard is broken? None.
Plus it gives a terrible school to newcomers. If you look at this group archives like 2-3 years ago it will be full of questions like: how to access form element named "foo[]" - document.forms[0].foo[] doesn't work! and similar...
Which is why I always recommend accessing form elements with the syntax:
document.forms['formname'].elements['elementname']
This will cause no problems with form fields with '[]' in them.
--
Matt Kruse http://www.JavascriptToolbox.com http://www.AjaxToolbox.com
VK said the following on 1/9/2006 5:32 PM:
<snip> I call this ugly because one should never break long time commonly accepted standards to implement your own freshly invented ones.
There are terms for breaking long time standards to implement your own:
progress
innovation
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
On Mon, 09 Jan 2006 17:22:52 +0100, in comp.lang.javascript , Thomas
'PointedEars' Lahn <Po*********@web.de> in
<20****************@PointedEars.de> wrote: Frances wrote:
[snip] 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.
Which makes me wonder what is the verifiably objectively wrong
statement with the largest number of Google hits?
--
Matt Silberstein
Do something today about the Darfur Genocide http://www.beawitness.org http://www.darfurgenocide.org http://www.savedarfur.org
"Darfur: A Genocide We can Stop"
Matt Silberstein wrote on 19 jan 2006 in comp.lang.javascript : Which makes me wonder what is the verifiably objectively wrong statement with the largest number of Google hits?
"True"
<http://www.google.com/search?q=true>
777,000,000 hits. [some of which are true, methinks]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Randy Webb wrote on 19 jan 2006 in comp.lang.javascript : Evertjan. said the following on 1/19/2006 11:47 AM: Matt Silberstein wrote on 19 jan 2006 in comp.lang.javascript: Which makes me wonder what is the verifiably objectively wrong statement with the largest number of Google hits?
"True"
"Not" :)
<http://www.google.com/search?q=true>
777,000,000 hits. [some of which are true, methinks]
<URL: http://www.google.com/search?q=not > 10,470,000,000 hits.
<URL: http://www.google.com/search?q=true > Shows me 1,190,000,000 hits.
However Not is an unary operator and not a statement in itself, it needs
true or false for completion.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Evertjan. said the following on 1/19/2006 6:28 PM: Randy Webb wrote on 19 jan 2006 in comp.lang.javascript:
Evertjan. said the following on 1/19/2006 11:47 AM: Matt Silberstein wrote on 19 jan 2006 in comp.lang.javascript: Which makes me wonder what is the verifiably objectively wrong statement with the largest number of Google hits? "True" "Not" :)
<http://www.google.com/search?q=true>
777,000,000 hits. [some of which are true, methinks] <URL: http://www.google.com/search?q=not > 10,470,000,000 hits.
<URL: http://www.google.com/search?q=true > Shows me 1,190,000,000 hits.
However Not is an unary operator and not a statement in itself, it needs true or false for completion.
Why? http://www.google.com/search?q=why
2,760,000,000 hits
But you are right about Not.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Randy Webb wrote on 20 jan 2006 in comp.lang.javascript : Why?
http://www.google.com/search?q=why 2,760,000,000 hits
But you are right about Not.
A negative expression, Randy.
Or was it ment to be:
"But you are right about Knot" ?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul Thompson |
last post by:
I am trying to use various javascript tools, all of which work in NN, to
work in IE.
Here's my latest annoyance.
I get a list of all objects on a page using
docContents =...
|
by: bloc |
last post by:
I am programming an interactive CV using xml, xslt and java script. The
page consists of a header which contains links to various 'sections' on
the xml cv, a left and right menu, and a central...
|
by: den2005 |
last post by:
Hi everybody,
Problem with dragging effect of resizing is working but having problem with setting a flag to determine if mouse button is click or not. Is there anyone knows how to fixed this? I...
|
by: Nitu Kumar Patra |
last post by:
I want to get the value of the to ,cc, bcc fields of hotmail in netscape browser using
getElementsByName("to").value. But it is not working. How to retrieve these values can anyone tell me?
Thanks
|
by: srini |
last post by:
Frens,
I am trying to get screen resolution of the client machine using
javascript and use those values in my project. I looked at some of the
examples given in this group, i tried to implement...
|
by: gsreenathreddy |
last post by:
Hi!
<html>
<head>
<script type="text/javascript">
function upperCase()
{
var x=document.getElementById("fname").value;
document.getElementById("fname").value=x.toUpperCase();
}
|
by: azura |
last post by:
dear sir..my friend give me one code how to calculate without pressing any button... but i didn't know how to insert function to make it work... very very newbie in calculation using...
|
by: shivasusan |
last post by:
I don't know how to change the text box name?
for ex:(my table like this)
sl. country from to
1 aaa (txt_c1) 5/4/09 (txt_f1) 5/13/09 (txt_t1) // Now i delete this row.
2 bbb (txt_c2) 5/18/09...
|
by: elham477 |
last post by:
I have two pages. The first page contain a table with title and the second contain texts & selected option.
I want it so when a user in second page clicks the submit button, his information is...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: isladogs |
last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, Mike...
|
by: SueHopson |
last post by:
Hi All,
I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...
| |