accessing a range of rows in table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • anagai

    accessing a range of rows in table

    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.

  • Jonas Raoni

    #2
    Re: accessing a range of rows in table

    anagai escreveu:[color=blue]
    > 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.[/color]

    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


    Comment

    • Gérard Talbot

      #3
      Re: accessing a range of rows in table

      anagai wrote :[color=blue]
      > 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.[/color]

      tBodies (HTML collection)


      No need to assign an id.


      Ive tried surrounding rows with a span tag, with[color=blue]
      > no success.[/color]

      That's invalid markup code to begin with.


      For now i will just have to use the old tbl.rows method to[color=blue]
      > 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[/color]

      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

      Comment

      • Jasen Betts

        #4
        Re: accessing a range of rows in table

        On 2006-01-06, anagai <andy.nagai@gma il.com> wrote:[color=blue]
        > hi
        >
        > I have a javascript function that will add a column of numbers in html
        > table.[/color]
        [color=blue]
        > 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?[/color]

        you could put all the rows in a tbody, and give that an ID.
        multiple tbodies are allowed in a table.
        [color=blue]
        > I have
        > tried surrounding rows with a tbody tag and assing a id to that. I cant
        > access it through dom.[/color]

        does your HTML validate?

        Bye.
        Jasen

        Comment

        • Andy Nagai

          #5
          Re: accessing a range of rows in table

          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 ***

          Comment

          Working...