table rows


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: table rows

  1. #1
    Grainne Guest

    table rows


    I am producing a table using xml. I want to assign a row number to each row
    in the table. I have tried using the following code on the Body onLoad event:

    function AssignRow()
    {

    var tablerows = document.all.tags("TR");

    for (i=1; i<tablerows.length; i++)
    {
    tablerows.item(0).value = i;
    }
    }

    However, this assigns 1 to all the rows, then 2 to all the rows, etc so the
    final outcome is that if I have 32 rows, they all have the value 32.

    All suggestions welcome.



  2. #2
    Marc D'Aoust Guest

    Re: table rows

    I don't have mush experience in this area but, programmatically, shouldn't
    you be incrementing the index for "tablerows.item"

    Something like "tablerows.item(i).value = i;"

    Let me know if it helps any

    --
    Marc D'Aoust
    Director of R&D
    OSTNET Open Source Technologies Inc.
    mailto:marc_daoust@hotmail,com

    ----------------------------------------------------------------------------
    -----------------------
    "make things as simple as possible, but never any simpler then that"

    - Einstein

    "Grainne" <Grainne.McAnee@singularity.co.uk> wrote in message
    news:38eb3959$1@news.devx.com...
    >
    > I am producing a table using xml. I want to assign a row number to each

    row
    > in the table. I have tried using the following code on the Body onLoad

    event:
    >
    > function AssignRow()
    > {
    >
    > var tablerows = document.all.tags("TR");
    >
    > for (i=1; i<tablerows.length; i++)
    > {
    > tablerows.item(0).value = i;
    > }
    > }
    >
    > However, this assigns 1 to all the rows, then 2 to all the rows, etc so

    the
    > final outcome is that if I have 32 rows, they all have the value 32.
    >
    > All suggestions welcome.
    >
    >




  3. #3
    Homer Guest

    Re: table rows


    doah!

    "Marc D'Aoust" <marc_daoust@hotmail.com> wrote:
    >I don't have mush experience in this area but, programmatically, shouldn't
    >you be incrementing the index for "tablerows.item"
    >
    >Something like "tablerows.item(i).value = i;"
    >
    >Let me know if it helps any
    >
    >--
    >Marc D'Aoust
    >Director of R&D
    >OSTNET Open Source Technologies Inc.
    >mailto:marc_daoust@hotmail,com
    >
    >----------------------------------------------------------------------------
    >-----------------------
    >"make things as simple as possible, but never any simpler then that"
    >


    > - Einstein
    >
    >"Grainne" <Grainne.McAnee@singularity.co.uk> wrote in message
    >news:38eb3959$1@news.devx.com...
    >>
    >> I am producing a table using xml. I want to assign a row number to each

    >row
    >> in the table. I have tried using the following code on the Body onLoad

    >event:
    >>
    >> function AssignRow()
    >> {
    >>
    >> var tablerows = document.all.tags("TR");
    >>
    >> for (i=1; i<tablerows.length; i++)
    >> {
    >> tablerows.item(0).value = i;
    >> }
    >> }
    >>
    >> However, this assigns 1 to all the rows, then 2 to all the rows, etc so

    >the
    >> final outcome is that if I have 32 rows, they all have the value 32.
    >>
    >> All suggestions welcome.
    >>
    >>

    >
    >



  4. #4
    Gilberto Guest

    Re: table rows


    Take a look in MSDN you can find an example there..

    thanks

    Gilbert

    "Homer" <hsimpson@thesimpsons.net> wrote:
    >
    >doah!
    >
    >"Marc D'Aoust" <marc_daoust@hotmail.com> wrote:
    >>I don't have mush experience in this area but, programmatically, shouldn't
    >>you be incrementing the index for "tablerows.item"
    >>
    >>Something like "tablerows.item(i).value = i;"
    >>
    >>Let me know if it helps any
    >>
    >>--
    >>Marc D'Aoust
    >>Director of R&D
    >>OSTNET Open Source Technologies Inc.
    >>mailto:marc_daoust@hotmail,com
    >>
    >>----------------------------------------------------------------------------
    >>-----------------------
    >>"make things as simple as possible, but never any simpler then that"
    >>


    >
    >> - Einstein
    >>
    >>"Grainne" <Grainne.McAnee@singularity.co.uk> wrote in message
    >>news:38eb3959$1@news.devx.com...
    >>>
    >>> I am producing a table using xml. I want to assign a row number to each

    >>row
    >>> in the table. I have tried using the following code on the Body onLoad

    >>event:
    >>>
    >>> function AssignRow()
    >>> {
    >>>
    >>> var tablerows = document.all.tags("TR");
    >>>
    >>> for (i=1; i<tablerows.length; i++)
    >>> {
    >>> tablerows.item(0).value = i;
    >>> }
    >>> }
    >>>
    >>> However, this assigns 1 to all the rows, then 2 to all the rows, etc

    so
    >>the
    >>> final outcome is that if I have 32 rows, they all have the value 32.
    >>>
    >>> All suggestions welcome.
    >>>
    >>>

    >>
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center