471,887 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

Multiple tables sharing same cell IDs - only update one

127 100+
Hi all,

Could someone please tell (remind) me how I can use "document.getElementById('cellID').innerHTML" for a specific cell for a specific table, given that two tables share the same cell ID names, but I only want to update one of them.

May 11 '09 #1
8 2647
8,658 Expert Mod 8TB
an ID must not occur more than once. (it's how IDs are defined). otherwise use classes or names.
Expand|Select|Wrap|Line Numbers
  1. document.getElementsByName(__NAME__)[0]; // first element with a given name
May 11 '09 #2
127 100+
Thanks for the reply!

So even if I have unique IDs for each table, the cell IDs for both tables cannot be duplicated? Bah!!!!
May 11 '09 #3
5,390 Expert Mod 4TB
it is not 'Bah!!!!' :) ... in case it wouldn't be as it is how should the dom parser find an element by id with:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('id');
the method always returns one node and in case there are nodes with the same id which one should it choose? ... an id currently has to be unique in one document ...

kind regards
May 11 '09 #4
8,658 Expert Mod 8TB
I hope that's not gonna changing ever…
May 11 '09 #5
5,390 Expert Mod 4TB
may be you could sometimes use:

Expand|Select|Wrap|Line Numbers
  1. myNode.getElementById('myId');
:) but i know what you mean and i'm with you :)
May 12 '09 #6
16,027 Expert Mod 8TB
You should never need to use duplicate IDs. You can always give it IDs such as "c111" where the first 1 can be the table, the second the row and the third the cell (this is based on what I remember you naming your cells from earlier posts).
May 12 '09 #7
127 100+
Thanks for the replies!

I resorted to "acoder"'s suggestion. I figured that as tables act as parents for their respective cells, it would be logical that prefixing a cell ID with it's parent (table) using document.get would allow duplicate cell IDs. I guess I've quite a bit to learn!
May 12 '09 #8
16,027 Expert Mod 8TB
Well, they wouldn't be duplicates then, they'd be unique which of course solves the problem.
May 12 '09 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by RJ | last post: by
5 posts views Thread by sds | last post: by
1 post views Thread by Justin | last post: by
8 posts views Thread by Jason L James | last post: by
16 posts views Thread by Randy Harris | last post: by
7 posts views Thread by =?Utf-8?B?TG9zdEluTUQ=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.