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

accessing a range of rows in table

P: n/a
hi

I have a javascript function that will add a column of numbers in html
table. Is there a way to assign a ID to a group of table rows that so i
can easily access the rows through getelementbyid and childnode? I have
tried surrounding rows with a tbody tag and assing a id to that. I cant
access it through dom. Ive tried surrounding rows with a span tag, with
no success. For now i will just have to use the old tbl.rows method to
access the rows. This method is clusmy if you want to make a reusable
function for summing data and need to ignore all the extra rows such as
title and spacer rows.

Jan 6 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
anagai escreveu:
For now i will just have to use the old tbl.rows method to
access the rows. This method is clusmy if you want to make a reusable
function for summing data and need to ignore all the extra rows such as
title and spacer rows.


I don't see anything wrong with the rows property...

Anyway, what you're trying to do is possible, have you ever seen those
"javascript css selectors"? You could make an extended version or just
make a function where you send an element list and a callback function
to filter those who matched your criteria... Maybe it's also possible
to achieve your goal with xpath (I didn't read about it yet)... But if
you can do it using simple js, why not? :)

There are certain circunstances where it isn't possible to make a 100%
reusable code, but if you can reuse 70% of it or at least the most
annoying part, it's already great :)

It's just my opinion =]
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com

Jan 6 '06 #2

P: n/a
anagai wrote :
hi

I have a javascript function that will add a column of numbers in html
table. Is there a way to assign a ID to a group of table rows that so i
can easily access the rows through getelementbyid and childnode? I have
tried surrounding rows with a tbody tag and assing a id to that. I cant
access it through dom.
tBodies (HTML collection)
http://www.w3.org/TR/DOM-Level-2-HTM...ml#ID-63206416

No need to assign an id.
Ive tried surrounding rows with a span tag, with no success.
That's invalid markup code to begin with.
For now i will just have to use the old tbl.rows method to access the rows. This method is clusmy if you want to make a reusable
function for summing data and need to ignore all the extra rows such as
title


title? You mean column headers semantically identified as <th>?
and spacer rows.

Are you actually using some sort of code like
<tr><td><img src="spacer.gif" width="..." height="..."
alt=""></td><td><img src="spacer.gif" width="..." height="..."
alt=""></td></tr>

Why not use cellspacing's table attribute?

If you have added a column of numbers and want to access that column of
table cells, then why not just do that?
You have not posted an url so it's difficult to know for sure what your
code might be needing.

Gérard
--
remove blah to email me
Jan 7 '06 #3

P: n/a
On 2006-01-06, anagai <an********@gmail.com> wrote:
hi

I have a javascript function that will add a column of numbers in html
table. Is there a way to assign a ID to a group of table rows that so i
can easily access the rows through getelementbyid and childnode?
you could put all the rows in a tbody, and give that an ID.
multiple tbodies are allowed in a table.
I have
tried surrounding rows with a tbody tag and assing a id to that. I cant
access it through dom.


does your HTML validate?

Bye.
Jasen
Jan 8 '06 #4

P: n/a
seems my problem has been not setting the <Doctype ... tag. All i want
to do is assign a id to a <tbody tag and use that. apparently a page
with the doctype not set will not allow you to reference a tbody by ID.
I have a another page with doctype set and now i can find those section
of rows. i had no idea.

*** Sent via Developersdex http://www.developersdex.com ***
Jan 8 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.