Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #19463
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "Tony" <tony.johansson@inport.com> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: How do I use getElementById in my situation |
| Date | Thu, 25 Apr 2013 11:29:46 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 1 |
| Message-ID | <klassf$l35$1@dont-email.me> (permalink) |
| References | <klar57$cfi$1@dont-email.me> <klas9o$idf$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; format=flowed; charset="iso-8859-1"; reply-type=response |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 25 Apr 2013 09:26:39 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="04290fff4557273ca84c3ad616751e0b"; logging-data="21605"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ItR8Niff4T7osx4r+Vo4e/ZowCMqMQRs=" |
| X-MimeOLE | Produced By Microsoft MimeOLE V15.4.3555.308 |
| In-Reply-To | <klas9o$idf$1@dont-email.me> |
| X-Newsreader | Microsoft Windows Live Mail 15.4.3555.308 |
| Importance | Normal |
| Cancel-Lock | sha1:e5bbm1TE0WgSXTQeJQTpRae+y+U= |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| Xref | csiph.com comp.lang.javascript:19463 |
Show key headers only | View raw
"Jukka K. Korpela" wrote in message news:klas9o$idf$1@dont-email.me...
2013-04-25 12:00, Tony wrote:
> I have a for loop from 0 to 8 and I want to fetch the DOM element id
> that is called elem0, elem1, elem2, elem3, elem4 , elem5, elem6, elem7,
> elem8 like this
> for (var i = 0; i < antalColumner; i++) //0 - 7
> {
> var item = "elem" + i;
> elem = document.getElementById(item);
> }
>
> I must make the getElementById to understand that I want "elem0" and
> "elem1" and so on
So what is the problem? That seems to be what you are doing here. You
are not using the value of the variable elem for anything, but that's a
different issue.
On the other hand, if this is about processing a table, as the variable
name antalColumner suggests, you could just traverse the table row by
row and cell by cell, without needing id attributes.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
When I do this
elem = document.getElementById(item);
elem is null
//Tony
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How do I use getElementById in my situation "Tony" <tony.johansson@inport.com> - 2013-04-25 11:00 +0200
Re: How do I use getElementById in my situation "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-04-25 12:19 +0300
Re: How do I use getElementById in my situation "Tony" <tony.johansson@inport.com> - 2013-04-25 11:29 +0200
Re: How do I use getElementById in my situation "Tony" <tony.johansson@inport.com> - 2013-04-25 11:32 +0200
Re: How do I use getElementById in my situation "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2013-04-25 12:35 +0300
csiph-web