Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30312 > unrolled thread

Using getElementsByName on a DIV ?

Started by"R.Wieser" <address@not.available>
First post2016-04-25 19:37 +0200
Last post2016-05-04 19:04 -0700
Articles 20 on this page of 36 — 10 participants

Back to article view | Back to comp.lang.javascript


Contents

  Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-25 19:37 +0200
    Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-25 20:57 +0200
      Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-25 20:10 +0100
        Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-25 21:42 +0200
          Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-25 23:07 +0100
            Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 09:32 +0200
              Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-26 11:28 +0100
                Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 14:52 +0200
                  Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-26 14:40 +0100
                    Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 18:37 +0200
                      Re: Using getElementsByName on a DIV ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-04-26 19:12 +0200
                        Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 20:44 +0200
                      Re: Using getElementsByName on a DIV ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-26 19:17 +0200
                      Re: Using getElementsByName on a DIV ? Stefan Weiss <krewecherl@gmail.com> - 2016-04-26 19:56 +0200
                        Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 22:11 +0200
                      Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-26 19:40 +0100
                        Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 21:43 +0200
                          Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-27 00:14 +0100
                            Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-27 11:05 +0200
                              Re: Using getElementsByName on a DIV ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-28 01:10 +0100
                                Re: Using getElementsByName on a DIV ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-05 00:46 +0200
                                  Re: Using getElementsByName on a DIV ? "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-05-06 12:56 +0200
                                    Re: Using getElementsByName on a DIV ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-06 05:14 -0700
                                Re: Using getElementsByName on a DIV ? John Harris <niam@jghnorth.org.uk.invalid> - 2016-05-05 14:36 +0100
                      Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 20:38 +0200
          Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 08:57 +0200
    Re: Using getElementsByName on a DIV ? Stefan Weiss <krewecherl@gmail.com> - 2016-04-25 23:41 +0200
      Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 08:59 +0200
    Re: Using getElementsByName on a DIV ? JJ <jj4public@vfemail.net> - 2016-04-26 19:03 +0700
      Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-26 14:56 +0200
      Re: Using getElementsByName on a DIV ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-26 20:13 +0200
        Re: Using getElementsByName on a DIV ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-26 20:19 +0200
    Re: Using getElementsByName on a DIV ? Dr J R Stockton <reply1600@merlyn.demon.co.uk.invalid> - 2016-04-26 23:30 +0100
      Re: Using getElementsByName on a DIV ? "R.Wieser" <address@not.available> - 2016-04-27 09:29 +0200
      Re: Using getElementsByName on a DIV ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-04-27 10:34 +0200
      Re: Using getElementsByName on a DIV ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-05-04 19:04 -0700

Page 1 of 2  [1] 2  Next page →


#30312 — Using getElementsByName on a DIV ?

From"R.Wieser" <address@not.available>
Date2016-04-25 19:37 +0200
SubjectUsing getElementsByName on a DIV ?
Message-ID<571e5590$0$5835$e4fe514c@news.xs4all.nl>
Hello all,

I need to find an IMG element in a DIV.   I have written some code to do
just that, but suddenly thought of using getElementsByName on the DIV node.
Alas, that does not seem to work.

#1: can I use getElementsBy* to find sub-elements of a DIV (or other
grouping element) at all ?

#2: if the answer to #1 is "no", is there another command that will do it ?
A google search did not turn up anything in that regard.

Mind you, I've already written a solution.  I'm just wondering if my
multi-line recursive function could be replaced by a simpler, single
command.

Now I think of it, I've got pretty-much the same question in regard to
finding an "ancestor" element:  I've written some code which moves up the
DOM tree until it finds the sought for element, but maybe there is a
simpler, single command available for that too.

Regards,
Rudy Wieser


[toc] | [next] | [standalone]


#30314

From"R.Wieser" <address@not.available>
Date2016-04-25 20:57 +0200
Message-ID<571e6847$0$5912$e4fe514c@news.xs4all.nl>
In reply to#30312
Stefan,

>   div.getElementsByTagName( "img" ) // untested

Well, I used the result of "parentNode" (instead of "div"), and that
certainly didn't work for me.

>   »getElementsByTagName« belongs to the interfaces
> »Document« and »Element«. See www.w3.org/TR/dom/.

That document is less than six months old.  I would like to use something
that works on a bit more than just the very latest of browsers if you don't
mind.

Regards,
Rudy Wieser


-- Origional message:
Stefan Ram <ram@zedat.fu-berlin.de> schreef in berichtnieuws
getElementsByTagName-20160425193302@ram.dialup.fu-berlin.de...
> "R.Wieser" <address@not.available> writes:
> >I need to find an IMG element in a DIV.
>
>   div.getElementsByTagName( "img" ) // untested
>
> >#1: can I use getElementsBy* to find sub-elements of a DIV (or other
> >grouping element) at all ?
>
>   »getElementsByTagName« belongs to the interfaces »Document«
>   and »Element«. See www.w3.org/TR/dom/.
>

[toc] | [prev] | [next] | [standalone]


#30316

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-04-25 20:10 +0100
Message-ID<8760v5a4ic.fsf@bsb.me.uk>
In reply to#30314
"R.Wieser" <address@not.available> writes:

> Stefan,
>
>>   div.getElementsByTagName( "img" ) // untested
>
> Well, I used the result of "parentNode" (instead of "div"), and that
> certainly didn't work for me.
>
>>   »getElementsByTagName« belongs to the interfaces
>> »Document« and »Element«. See www.w3.org/TR/dom/.
>
> That document is less than six months old.  I would like to use something
> that works on a bit more than just the very latest of browsers if you don't
> mind.

getElementsByTagName is one of the oldest methods.  It's specified in
the first version of the DOM (about 1998).  If it did not work, it's not
for being the new boy in town.

Can you say more than just that it didn't work for you?

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#30317

From"R.Wieser" <address@not.available>
Date2016-04-25 21:42 +0200
Message-ID<571e72f0$0$5941$e4fe514c@news.xs4all.nl>
In reply to#30316
Ben,

> If it did not work, it's not for being the new boy in town.

Thats what I thought too, but that document made me doubt it ...

> Can you say more than just that it didn't work for you?

Well.   The FF Javascript Console told me that "Ancestor.getElementsByName
is not a function" (the "Ancestor" variable contains a "parentNode" result).

When I display the "Ancestor" variables contents in an "alert" box it shows
"object HTMLDivElement", which looks to be correct to me.

Thats about it.   Anything else I can check ?

By the way, my apologies.  I should not have used (the rather meaningless)
"doesn't work" phrase.  At least not without some more explaining.   :-\

Regards,
Rudy Wieser


-- Origional message:
Ben Bacarisse <ben.usenet@bsb.me.uk> schreef in berichtnieuws
8760v5a4ic.fsf@bsb.me.uk...
> "R.Wieser" <address@not.available> writes:
>
> > Stefan,
> >
> >>   div.getElementsByTagName( "img" ) // untested
> >
> > Well, I used the result of "parentNode" (instead of "div"), and that
> > certainly didn't work for me.
> >
> >>   »getElementsByTagName« belongs to the interfaces
> >> »Document« and »Element«. See www.w3.org/TR/dom/.
> >
> > That document is less than six months old.  I would like to use
something
> > that works on a bit more than just the very latest of browsers if you
don't
> > mind.
>
> getElementsByTagName is one of the oldest methods.  It's specified in
> the first version of the DOM (about 1998).  If it did not work, it's not
> for being the new boy in town.
>
> Can you say more than just that it didn't work for you?
>
> <snip>
> --
> Ben.

[toc] | [prev] | [next] | [standalone]


#30321

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-04-25 23:07 +0100
Message-ID<87zish8hqk.fsf@bsb.me.uk>
In reply to#30317
"R.Wieser" <address@not.available> writes:

>> If it did not work, it's not for being the new boy in town.
>
> Thats what I thought too, but that document made me doubt it ...
>
>> Can you say more than just that it didn't work for you?
>
> Well.   The FF Javascript Console told me that "Ancestor.getElementsByName
> is not a function" (the "Ancestor" variable contains a "parentNode"
> result).

Stefan has explained the basic issue (using getElementsByName instead of
getElementsByTagName) but you might be curious at to why you get this
error.  getElementsByName is not a method of elements but only of
documents.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#30329

From"R.Wieser" <address@not.available>
Date2016-04-26 09:32 +0200
Message-ID<571f1936$1$5824$e4fe514c@news.xs4all.nl>
In reply to#30321
Ben,

> getElementsByName is not a method of elements but
> only of documents.

Yes, thats what I concluded too (but as a novice in this regard wanted to
verify it), and why I asked if there was another command that would indeed
work
for elements.

Hmmm ...  It looks that the only "document.getElementsBy*" command that
wishes to work *at all* on the browser I'm using for testing is the
"TagName" one ... Bummer.

Regards,
Rudy Wieser


-- Origional message:
Ben Bacarisse <ben.usenet@bsb.me.uk> schreef in berichtnieuws
87zish8hqk.fsf@bsb.me.uk...
> "R.Wieser" <address@not.available> writes:
>
> >> If it did not work, it's not for being the new boy in town.
> >
> > Thats what I thought too, but that document made me doubt it ...
> >
> >> Can you say more than just that it didn't work for you?
> >
> > Well.   The FF Javascript Console told me that
"Ancestor.getElementsByName
> > is not a function" (the "Ancestor" variable contains a "parentNode"
> > result).
>
> Stefan has explained the basic issue (using getElementsByName instead of
> getElementsByTagName) but you might be curious at to why you get this
> error.  getElementsByName is not a method of elements but only of
> documents.
>
> <snip>
> --
> Ben.



[toc] | [prev] | [next] | [standalone]


#30332

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-04-26 11:28 +0100
Message-ID<87d1pc8xzs.fsf@bsb.me.uk>
In reply to#30329
"R.Wieser" <address@not.available> writes:

>> getElementsByName is not a method of elements but
>> only of documents.
>
> Yes, thats what I concluded too (but as a novice in this regard wanted
> to verify it), and why I asked if there was another command that would
> indeed work for elements.
>
> Hmmm ...  It looks that the only "document.getElementsBy*" command that
> wishes to work *at all* on the browser I'm using for testing is the
> "TagName" one ... Bummer.

Well you should also have getElementsByTagNameNS but that's a
technicality.  However, you might still be confusing document
methods with element methods since you originally asked about looking
inside a div (which will be modelled as an element) and here you are
taking about document.getElementsBy* methods.

There does not seem to be anything odd about what you are trying to do,
so I'm a bit lost as to why you can't find what you need.  What is the
high-level task you are trying to achieve?

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#30335

From"R.Wieser" <address@not.available>
Date2016-04-26 14:52 +0200
Message-ID<571f6433$0$5816$e4fe514c@news.xs4all.nl>
In reply to#30332
Ben,

> However, you might still be confusing document methods
> with element methods

Possibly.    I do not really see a difference between a "document" and an
"element", as I consider the former to be the top element/node of the
element/node tree.

> What is the high-level task you are trying to achieve?

The only reason you would want to know that is to try to find another
approach to what I'm trying to do (a work-around).   Which is not what I'm
looking for.

All I currently want is to figure out if there is a simple way to find a
descendant of a certain element, and as that seems to be quite possible
figure out why I can't get it to work.

If I do not solve it now I will just run into it again at some later date.
:-\

Reminder: I already wrote some code to do what I want (even rewrote it this
morning to return all matching elements, not only the first).   But using
that code when there is an build-in method available is not really what I
would like to do.

Regards,
Rudy Wieser


-- Origional message:
Ben Bacarisse <ben.usenet@bsb.me.uk> schreef in berichtnieuws
87d1pc8xzs.fsf@bsb.me.uk...
> "R.Wieser" <address@not.available> writes:
>
> >> getElementsByName is not a method of elements but
> >> only of documents.
> >
> > Yes, thats what I concluded too (but as a novice in this regard wanted
> > to verify it), and why I asked if there was another command that would
> > indeed work for elements.
> >
> > Hmmm ...  It looks that the only "document.getElementsBy*" command that
> > wishes to work *at all* on the browser I'm using for testing is the
> > "TagName" one ... Bummer.
>
> Well you should also have getElementsByTagNameNS but that's a
> technicality.  However, you might still be confusing document
> methods with element methods since you originally asked about looking
> inside a div (which will be modelled as an element) and here you are
> taking about document.getElementsBy* methods.
>
> There does not seem to be anything odd about what you are trying to do,
> so I'm a bit lost as to why you can't find what you need.  What is the
> high-level task you are trying to achieve?
>
> <snip>
> --
> Ben.

[toc] | [prev] | [next] | [standalone]


#30337

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-04-26 14:40 +0100
Message-ID<877ffk8p59.fsf@bsb.me.uk>
In reply to#30335
"R.Wieser" <address@not.available> writes:

> Ben,
>
>> However, you might still be confusing document methods
>> with element methods
>
> Possibly.    I do not really see a difference between a "document" and an
> "element", as I consider the former to be the top element/node of the
> element/node tree.

They are different types.  That is why they have different methods.

>> What is the high-level task you are trying to achieve?
>
> The only reason you would want to know that is to try to find another
> approach to what I'm trying to do (a work-around).   Which is not what I'm
> looking for.

But you need to say enough that people know how to offer help.  All I
know right now is that you want to fond an img in a div.  There's
usually no problem in doing that, so I'm not stuck about how you offer
any more help.

> All I currently want is to figure out if there is a simple way to find a
> descendant of a certain element, and as that seems to be quite possible
> figure out why I can't get it to work.

Yes, I'd like to figure that out too but I have no data to go on.  If
you posted an example document with the code that does work, it would
help a lot.

> If I do not solve it now I will just run into it again at some later date.
> :-\
>
> Reminder: I already wrote some code to do what I want (even rewrote it this
> morning to return all matching elements, not only the first).   But using
> that code when there is an build-in method available is not really what I
> would like to do.

Without knowing what you want, it's impossible to say.  But it's
unlikely that what you want is so general that one of the built-in
methods will do the job.  You can find elements by tag, by name, by id
and by class.  With newer browsers you can use more complex selections
(as posted about elsewhere in the thread), but that's it.  If what you
want is not any of these rather general tasks, then you'll have to write
more code than a single method call.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#30340

From"R.Wieser" <address@not.available>
Date2016-04-26 18:37 +0200
Message-ID<571f9907$0$5862$e4fe514c@news.xs4all.nl>
In reply to#30337
Ben,

> They are different types.  That is why they have different methods.

... and seemingly a number of the same ones, like the getElementsBy* ones --
which is what we where talking about.

> But you need to say enough that people know how to offer help.

As far as I can tell I have given you all requirements as well as all the
arguments and the result data.  I've posted the error message when I was
asked for it, and even offered results of a few tests I did myself.  What
more do you want/need ?

> There's usually no problem in doing that,

So, are there any UNusual situations in which it cannot or would refuse to ?

> Without knowing what you want, it's impossible to say.

[quote=myself]
All I currently want is to figure out if there is a simple way to find a
descendant of a certain element
[quote]

If you do not understand what I said there than you are welcome to ask for
clarification.

Ignoring info you're getting while complaining that you're not getting
anything isn't the way to go you know (it just frustrates both of us).

> Yes, I'd like to figure that out too but I have no data to go on.

Than *ask* for such data.  I'm no mindreader you know.   Tell me which test
results you need and I will try to get them for you.

> But it's unlikely that what you want is so general that one of
> the built-in methods will do the job

Than why the heck have we been talking about the "getElementsBy*" functions
?   Those seem to do exactly what I'm looking for.

The only question now is, why won't they work for me ?   Have I made a
mistake somewhere ?   Anything else ?

tl;dr:
If you do not help me to figure out what you need than I can't give you what
you need to help me.

Regards,
Rudy Wieser

-- Origional mesage:
Ben Bacarisse <ben.usenet@bsb.me.uk> schreef in berichtnieuws
877ffk8p59.fsf@bsb.me.uk...
> "R.Wieser" <address@not.available> writes:
>
> > Ben,
> >
> >> However, you might still be confusing document methods
> >> with element methods
> >
> > Possibly.    I do not really see a difference between a "document" and
an
> > "element", as I consider the former to be the top element/node of the
> > element/node tree.
>
> They are different types.  That is why they have different methods.
>
> >> What is the high-level task you are trying to achieve?
> >
> > The only reason you would want to know that is to try to find another
> > approach to what I'm trying to do (a work-around).   Which is not what
I'm
> > looking for.
>
> But you need to say enough that people know how to offer help.  All I
> know right now is that you want to fond an img in a div.  There's
> usually no problem in doing that, so I'm not stuck about how you offer
> any more help.
>
> > All I currently want is to figure out if there is a simple way to find a
> > descendant of a certain element, and as that seems to be quite possible
> > figure out why I can't get it to work.
>
> Yes, I'd like to figure that out too but I have no data to go on.  If
> you posted an example document with the code that does work, it would
> help a lot.
>
> > If I do not solve it now I will just run into it again at some later
date.
> > :-\
> >
> > Reminder: I already wrote some code to do what I want (even rewrote it
this
> > morning to return all matching elements, not only the first).   But
using
> > that code when there is an build-in method available is not really what
I
> > would like to do.
>
> Without knowing what you want, it's impossible to say.  But it's
> unlikely that what you want is so general that one of the built-in
> methods will do the job.  You can find elements by tag, by name, by id
> and by class.  With newer browsers you can use more complex selections
> (as posted about elsewhere in the thread), but that's it.  If what you
> want is not any of these rather general tasks, then you'll have to write
> more code than a single method call.
>
> <snip>
> --
> Ben.


[toc] | [prev] | [next] | [standalone]


#30342

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2016-04-26 19:12 +0200
Message-ID<nfo7hf$mgb$1@solani.org>
In reply to#30340
R.Wieser wrote:

> [quote=myself]
> All I currently want is to figure out if there is a simple way to find a
> descendant of a certain element
> [quote]

Yes, there is.  It seems to me that several ways already have been
pointed out in this thread, so to be brief, see
<https://jsfiddle.net/yraan33c/1/>.

-- 
Christoph M. Becker

[toc] | [prev] | [next] | [standalone]


#30350

From"R.Wieser" <address@not.available>
Date2016-04-26 20:44 +0200
Message-ID<571fc489$0$5825$e4fe514c@news.xs4all.nl>
In reply to#30342
Christoph,

> Yes, there is.  It seems to me that several ways already
> have been pointed out in this thread

And I think I responded to every one of those suggestions.

Regards,
Rudy Wieser


-- Origional messages:
Christoph M. Becker <cmbecker69@arcor.de> schreef in berichtnieuws
nfo7hf$mgb$1@solani.org...
> R.Wieser wrote:
>
> > [quote=myself]
> > All I currently want is to figure out if there is a simple way to find a
> > descendant of a certain element
> > [quote]
>
> Yes, there is.  It seems to me that several ways already have been
> pointed out in this thread, so to be brief, see
> <https://jsfiddle.net/yraan33c/1/>.
>
> --
> Christoph M. Becker
>

[toc] | [prev] | [next] | [standalone]


#30344

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-04-26 19:17 +0200
Message-ID<2804849.Jd4QlQrqpf@PointedEars.de>
In reply to#30340
Stefan Ram wrote:

> "R.Wieser" <address@not.available> writes:
>>... and seemingly a number of the same ones, like the getElementsBy* ones
>>-- which is what we where talking about.
> 
>   The DOM does not have an abstraction »the getElementsBy*
>   ones«. Instead it uses »interfaces«. Certain DOM element
>   types implement certain interfaces and certain interfaces
>   inherit from other interfaces.

Actually instead, certain _HTML_ element types (and those of other markup 
languages) are represented in the _document tree_ (also “DOM tree” per 
HTML5), which is the markup parse result, by certain element _object types_ 
which implement corresponding DOM interfaces, i.e. they (ought to) provide 
the properties and methods that are specified as attributes and methods of 
the interface that is implemented (those attributes are not to be confused 
with element attributes, although for some there is a connection).

<https://www.w3.org/TR/2014/REC-html5-20141028/infrastructure.html#dom-trees>
 
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#30345

FromStefan Weiss <krewecherl@gmail.com>
Date2016-04-26 19:56 +0200
Message-ID<nfoa4u$cu1$1@news.albasani.net>
In reply to#30340
R.Wieser wrote:
> [quote=myself]
> All I currently want is to figure out if there is a simple way to find a
> descendant of a certain element
> [quote]
> 
> If you do not understand what I said there than you are welcome to ask for
> clarification.
> 
> Ignoring info you're getting while complaining that you're not getting
> anything isn't the way to go you know (it just frustrates both of us).
> 
>> Yes, I'd like to figure that out too but I have no data to go on.
> 
> Than *ask* for such data.  I'm no mindreader you know.

This isn't helping at all. Quoting Ben:

| If you posted an example document with the code that does work, it
| would help a lot.

> The only question now is, why won't they work for me ?   Have I made a
> mistake somewhere ?   Anything else ?

Who knows? "Doesn't work" is not a useful problem description. Show the code
and we may be able to help you figure it out. Getting impatient with people
who are trying to help will likely have the opposite effect.


- stefan

[toc] | [prev] | [next] | [standalone]


#30352

From"R.Wieser" <address@not.available>
Date2016-04-26 22:11 +0200
Message-ID<571fcb38$0$5947$e4fe514c@news.xs4all.nl>
In reply to#30345
Stefan,

> This isn't helping at all. Quoting Ben:
>
> | If you posted an example document with the code that does
> | work, it would help a lot.

And you get the same answer: I think I gave everything to reproduce the
problem, but have not heard him, nor you for that matter, mention anything
about such an attempt.  Why ?

> Who knows? "Doesn't work" is not a useful problem description.

Yeah, yeah.  I already mentioned that I should not have said that without
some explanation.  Having fun kicking a dead horse ?

> Getting impatient with people who are trying to help will
> likely have the opposite effect.

*Not* getting impatient (if that is what you want to call it) got me nowhere
either.  Your point ?

To be honest, I tried to tap into the groups knowledge I assume must be here
somewhere, as its rather easy to miss some, to others, obvious stuff when
you're attempting something for the first time.

In other words, I tried to take a shortcut to stay outof common pitfalls.
Alas, it didn't work.

Although there is a silver lining though: talking with you guys caused me to
verify a number of assumptions I had made (like those getElementsBy*
functions being of a single family, all responding alike), and thereby found
that a few where incorrect.  That in return led to finding the answer of my
initial question. Yay!

Regards,
Rudy Wieser


-- Origional message:
Stefan Weiss <krewecherl@gmail.com> schreef in berichtnieuws
nfoa4u$cu1$1@news.albasani.net...
> R.Wieser wrote:
> > [quote=myself]
> > All I currently want is to figure out if there is a simple way to find a
> > descendant of a certain element
> > [quote]
> >
> > If you do not understand what I said there than you are welcome to ask
for
> > clarification.
> >
> > Ignoring info you're getting while complaining that you're not getting
> > anything isn't the way to go you know (it just frustrates both of us).
> >
> >> Yes, I'd like to figure that out too but I have no data to go on.
> >
> > Than *ask* for such data.  I'm no mindreader you know.
>
> This isn't helping at all. Quoting Ben:
>
> | If you posted an example document with the code that does work, it
> | would help a lot.
>
> > The only question now is, why won't they work for me ?   Have I made a
> > mistake somewhere ?   Anything else ?
>
> Who knows? "Doesn't work" is not a useful problem description. Show the
code
> and we may be able to help you figure it out. Getting impatient with
people
> who are trying to help will likely have the opposite effect.
>
>
> - stefan

[toc] | [prev] | [next] | [standalone]


#30348

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-04-26 19:40 +0100
Message-ID<87shy86wo0.fsf@bsb.me.uk>
In reply to#30340
"R.Wieser" <address@not.available> writes:

<snip>
>> But you need to say enough that people know how to offer help.
>
> As far as I can tell I have given you all requirements as well as all the
> arguments and the result data.  I've posted the error message when I was
> asked for it, and even offered results of a few tests I did myself.  What
> more do you want/need ?

You want to get a img from a div (and sometimes you say "find a
descendent of a certain element" which is even more vague).  Given that
specification I know you have the right method to call (though with the
more vague one, the firstChild property might be enough), but something
is not right because you want to "figure out why I can't get it to
work".

<snip>
>> Yes, I'd like to figure that out too but I have no data to go on.
>
> Than *ask* for such data.  I'm no mindreader you know.   Tell me which test
> results you need and I will try to get them for you.

I did: an example document with the code that does not work.

>> But it's unlikely that what you want is so general that one of
>> the built-in methods will do the job
>
> Than why the heck have we been talking about the "getElementsBy*" functions
> ?   Those seem to do exactly what I'm looking for.
>
> The only question now is, why won't they work for me ?   Have I made a
> mistake somewhere ?   Anything else ?

Yes, you've make a mistake somewhere.  If you'd like some help to find
out where, given an example document, state the element you'd like to
find and show the code that doesn't work.

> tl;dr:
> If you do not help me to figure out what you need than I can't give you what
> you need to help me.

You even quoted me asking:

>> ... If
>> you posted an example document with the code that does work, it would
>> help a lot.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#30351

From"R.Wieser" <address@not.available>
Date2016-04-26 21:43 +0200
Message-ID<571fc489$1$5825$e4fe514c@news.xs4all.nl>
In reply to#30348
Ben,

> You want to get a img from a div (and sometimes you say
> "find a descendent of a certain element" which is even more
> vague).

The former is nothing more than an *example* of the latter, and only given
because the latter seemed to be way to difficult to understand to some.

Funny though, as the above is pretty-much what the getElementsByTagName
seems to do ...

> (though with the more vague one, the firstChild property
> might be enough)

Thanks for *not* having mentioned that one before ... :-\

Than again, we where ofcourse already busy figuring out why a getElementsBy*
approach wouldn't work.

> but something is not right because you want to "figure
> out why I can't get it to work".

... for which I have tried (though to my embarrassment only after having
been propted) to provide any-and-all info I had, and could generate
otherwise.

> I did: an example document with the code that does not work.

You did ?    And I did not respond to that ?    Thats ... not good.

But wait, I distincly remember having mentioned how I got a specific
element, what the result was of using an "alert" box displaying the variable
the objects reference was placed in, as well as the full command I used and
the error I got when looking in FFs Javascript Console.    Thats all you
should need to reproduce the problem, isn't it ?

Lets see .... Yes, there it is: In my third post in this thread, and even
addressed at you, ben.

Now I think of it, you do not seem to have mentioned anything in regard to
(not) being able to reproduce the problem ...

> You even quoted me asking:

:-)   I hope you do realize that I can look back into all my own messages in
this thread ?

What you seem to refer to as "quoted" is nothing more than an integral copy
of the your message, and even marked as such.   If you look careful enough,
you might even see that the (most, if not all) actual quotes I'm using (in
the part before the "-- origional message:" marker) are also present in that
integral copy.

Regards,
Rudy Wieser


-- Origional message:
Ben Bacarisse <ben.usenet@bsb.me.uk> schreef in berichtnieuws
87shy86wo0.fsf@bsb.me.uk...
> "R.Wieser" <address@not.available> writes:
>
> <snip>
> >> But you need to say enough that people know how to offer help.
> >
> > As far as I can tell I have given you all requirements as well as all
the
> > arguments and the result data.  I've posted the error message when I was
> > asked for it, and even offered results of a few tests I did myself.
What
> > more do you want/need ?
>
> You want to get a img from a div (and sometimes you say "find a
> descendent of a certain element" which is even more vague).  Given that
> specification I know you have the right method to call (though with the
> more vague one, the firstChild property might be enough), but something
> is not right because you want to "figure out why I can't get it to
> work".
>
> <snip>
> >> Yes, I'd like to figure that out too but I have no data to go on.
> >
> > Than *ask* for such data.  I'm no mindreader you know.   Tell me which
test
> > results you need and I will try to get them for you.
>
> I did: an example document with the code that does not work.
>
> >> But it's unlikely that what you want is so general that one of
> >> the built-in methods will do the job
> >
> > Than why the heck have we been talking about the "getElementsBy*"
functions
> > ?   Those seem to do exactly what I'm looking for.
> >
> > The only question now is, why won't they work for me ?   Have I made a
> > mistake somewhere ?   Anything else ?
>
> Yes, you've make a mistake somewhere.  If you'd like some help to find
> out where, given an example document, state the element you'd like to
> find and show the code that doesn't work.
>
> > tl;dr:
> > If you do not help me to figure out what you need than I can't give you
what
> > you need to help me.
>
> You even quoted me asking:
>
> >> ... If
> >> you posted an example document with the code that does work, it would
> >> help a lot.
>
> <snip>
> --
> Ben.

[toc] | [prev] | [next] | [standalone]


#30354

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-04-27 00:14 +0100
Message-ID<87a8kg6jz8.fsf@bsb.me.uk>
In reply to#30351
"R.Wieser" <address@not.available> writes:
<snip>

>> I did: an example document with the code that does not work.
>
> You did ?    And I did not respond to that ?    Thats ... not good.
>
> But wait, I distincly remember having mentioned how I got a specific
> element, what the result was of using an "alert" box displaying the variable
> the objects reference was placed in, as well as the full command I used and
> the error I got when looking in FFs Javascript Console.    Thats all you
> should need to reproduce the problem, isn't it ?

Not always, no.  But that part of the thread was fine: I asked "can you
say more" and you did.  You said enough to explain the error --
getElementsByName is simply not a method of elements.

> Lets see .... Yes, there it is: In my third post in this thread, and even
> addressed at you, ben.
>
> Now I think of it, you do not seem to have mentioned anything in regard to
> (not) being able to reproduce the problem ...

But that problem was immediately explained -- getElementsByName is not a
method of elements but of documents.  Is that was you have been
discussing ever since -- that one incorrect method call?  I thought you
understood why it will not work.  My request for an example was not a
request to repeat that example.

If there is something else not working, please give an example document.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#30359

From"R.Wieser" <address@not.available>
Date2016-04-27 11:05 +0200
Message-ID<572080a7$0$5941$e4fe514c@news.xs4all.nl>
In reply to#30354
Ben,

> Thats all you should need to reproduce the problem, isn't it ?
>
> Not always, no.

Somehow the above gives me the feeling that you are trying to generalize,
which in turn seems to indicate you've not yet tried to reproduce anything.
Hmmm...

> getElementsByName is not a method of elements but of
> documents.  Is that was you have been discussing ever
> since -- that one incorrect method call?

If you read back you can see that I referred to that command as, as I
thought, being part of a family.   I used that specific command as a
place-holder (could as easily have taken any of the others).

> I thought you understood why it will not work.

Nope.   How could I ?    Novice here (in regard to JS), remember.

As mentioned later, I assumed that I was working with a family of commands
(all working the same, just on different parts of an element), as well that
the "document" and "element" in regard to these commands could be used
interchangably (still see no logical reason to why that isn't so).

Turns out that both of those assumptions where false.   Which I had to
figure out for myself. :-\

> If there is something else not working, please give an example document.

Well, I tried to do that (just not as a cut-and-paste one), and it got
pretty-much ignored.

Do I *really* need to spoon-feed the/a problem like in the below ?

[javascript]
Ancestor = this.parentNode;
aDescendants = Ancestor.getElementsByTagName("IMG");
// aDescendants = Ancestor.getElementsByName("foobar");
// aDescendants = Ancestor.getElementsByClassName("foobar");
// oDescendant = Ancestor.getElementByID("foobar");
[/javascript]

I thought that should have been clear from my problem description.   But I
guess I expected too much ...

Regards,
Rudy Wieser


- Origional message:
Ben Bacarisse <ben.usenet@bsb.me.uk> schreef in berichtnieuws
87a8kg6jz8.fsf@bsb.me.uk...
> "R.Wieser" <address@not.available> writes:
> <snip>
>
> >> I did: an example document with the code that does not work.
> >
> > You did ?    And I did not respond to that ?    Thats ... not good.
> >
> > But wait, I distincly remember having mentioned how I got a specific
> > element, what the result was of using an "alert" box displaying the
variable
> > the objects reference was placed in, as well as the full command I used
and
> > the error I got when looking in FFs Javascript Console.    Thats all you
> > should need to reproduce the problem, isn't it ?
>
> Not always, no.  But that part of the thread was fine: I asked "can you
> say more" and you did.  You said enough to explain the error --
> getElementsByName is simply not a method of elements.
>
> > Lets see .... Yes, there it is: In my third post in this thread, and
even
> > addressed at you, ben.
> >
> > Now I think of it, you do not seem to have mentioned anything in regard
to
> > (not) being able to reproduce the problem ...
>
> But that problem was immediately explained -- getElementsByName is not a
> method of elements but of documents.  Is that was you have been
> discussing ever since -- that one incorrect method call?  I thought you
> understood why it will not work.  My request for an example was not a
> request to repeat that example.
>
> If there is something else not working, please give an example document.
>
> <snip>
> --
> Ben.

[toc] | [prev] | [next] | [standalone]


#30377

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2016-04-28 01:10 +0100
Message-ID<877ffi619z.fsf@bsb.me.uk>
In reply to#30359
"R.Wieser" <address@not.available> writes:
<snip>

>> If there is something else not working, please give an example document.
>
> Well, I tried to do that (just not as a cut-and-paste one), and it got
> pretty-much ignored.

Maybe you are not sure what a document is?  It's the full HTML (often
called a page) along with the script that is going wrong.  That's often
part of the document, but if it isn't you'd have to provide that as
well.

> Do I *really* need to spoon-feed the/a problem like in the below ?

No, you really have to provide an example document along with the code
that doesn't work.

> [javascript]
> Ancestor = this.parentNode;
> aDescendants = Ancestor.getElementsByTagName("IMG");
> // aDescendants = Ancestor.getElementsByName("foobar");
> // aDescendants = Ancestor.getElementsByClassName("foobar");
> // oDescendant = Ancestor.getElementByID("foobar");
> [/javascript]
>
> I thought that should have been clear from my problem description.   But I
> guess I expected too much ...

This isn't an example document.  One trouble with being a beginner is
that you may not know where the problem is, which is why a complete
self-contained example is so important.

Without one, all I can do is guess -- maybe there are no img elements in
this.parentNode?  Maybe 'this' is bound to the wrong type of object?
How many guesses do you want people to make before you simply provide a
document (and code) that exhibits the problem?

Just to be clear, I've cut and pasted your lines into a minimal document
and it does what I think you want.  The problem (whatever it is) is
elsewhere.

One thing is sure: if aDescendants is an element (as seems likely, but
without a full example that's just a guess) the calls to
getElementsByName and to getElementByID won't work.  These are methods
that are part of the document interface, not the element interface.

<snip>
-- 
Ben.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web