accessing a range of rows in table

Discussion in 'Javascript' started by anagai, Jan 6, 2006.

  1. anagai

    anagai Guest

    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.
     
    anagai, Jan 6, 2006
    #1
    1. Advertising

  2. anagai

    Jonas Raoni Guest

    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
     
    Jonas Raoni, Jan 6, 2006
    #2
    1. Advertising

  3. 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-HTML/html.html#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
     
    Gérard Talbot, Jan 6, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Subba Rao via DotNetMonster.com

    script for moving rows up and down and traverse thru rows of HTML table

    Subba Rao via DotNetMonster.com, Mar 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    8,318
    Subba Rao via DotNetMonster.com
    Mar 19, 2005
  2. Rio
    Replies:
    4
    Views:
    1,228
  3. Replies:
    46
    Views:
    992
    Antoon Pardon
    Jul 25, 2006
  4. Lambda
    Replies:
    2
    Views:
    420
    James Kanze
    Jul 16, 2008
  5. Tomoyuki Kosimizu

    Range does not take an Range object.

    Tomoyuki Kosimizu, Nov 25, 2003, in forum: Ruby
    Replies:
    3
    Views:
    163
    Tomoyuki Kosimizu
    Nov 27, 2003
Loading...

Share This Page