By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,495 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,495 IT Pros & Developers. It's quick & easy.

using getobjectbyname javascript

P: 3
hi
i have a table let say 10x10
how can i go to each td and check the innerhtml value without giving an id
for each td
i canot give an id for each td because the table is build by a function
thank u
( i am trying to build a cross puzzel with a javascript code and i nedd to know the value of each td)
Dec 16 '09 #1
Share this Question
Share on Google+
5 Replies


Dormilich
Expert Mod 5K+
P: 8,639
how can i go to each td and check the innerhtml value without giving an id for each td
loop through all cells of that table, returned by getElementsByTagName()

i canot give an id for each td because the table is build by a function
that is a lame excuse. although I admit, generating IDs is not very convenient.

a simple example in PHP could look like
Expand|Select|Wrap|Line Numbers
  1. echo '<td id="cell' . $count++ . '">cell content</td>';
Dec 16 '09 #2

P: 3
thanks but can u be more specifice with the answers is javascript
not php
what do u meen by loop what kind of loop
Dec 16 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
what do u meen by loop what kind of loop
whatever you like. for, while, do … while, pick one of them.

can u be more specifice with the answers is javascript
what kind of more specific? the principle of creating the IDs ain’t much different in other languages, including JavaScript.
Dec 16 '09 #4

acoder
Expert Mod 15k+
P: 16,027
If you're going to use elem.getElementsByTagName("td") (elem being the table or tbody element), there's no need to set any IDs. Check out a simple JavaScript tutorial on the different types of loops (see the off-site links thread for some links). If you're familiar with a C-style language, JavaScript loops should be pretty easy to pick up.
Dec 22 '09 #5

P: 3
thank u very much u where very helpfull
Dec 22 '09 #6

Post your reply

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