Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > accessing a range of rows in table

Reply
Thread Tools

accessing a range of rows in table

 
 
anagai
Guest
Posts: n/a
 
      01-06-2006
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.

 
Reply With Quote
 
 
 
 
Jonas Raoni
Guest
Posts: n/a
 
      01-06-2006
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

 
Reply With Quote
 
 
 
 
Gérard Talbot
Guest
Posts: n/a
 
      01-06-2006
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving dynamically created table rows up and down in an HTML table T.G. Javascript 2 10-14-2008 12:56 PM
table.rows vs. table.getElementsByTagName (+ a regex question) eBob.com Javascript 5 05-20-2008 10:58 AM
script for moving rows up and down and traverse thru rows of HTML table Subba Rao via DotNetMonster.com ASP .Net 0 03-19-2005 06:46 AM
Table/table rows/table data tag question? Rio HTML 4 11-05-2004 08:11 AM
Help ASP; get last inserted value from one table, insert multiple rows in another table. PT ASP General 1 10-07-2004 07:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57