Dynamically created rows in table are not following the StyleSheetrules

Discussion in 'Javascript' started by Raghuram Banda, Nov 7, 2003.

  1. Hi all,

    I've created a table with Table Header and the table may or may not
    contain any rows initially.
    I've included a .css file in <head> section of my HTML script and I'm
    creating rows to the table
    dynamically using JavaScript (using DOM), and the problem is those
    created bby DOM are not
    following style sheet rules applicable for table rows and cells. But the
    rows created from within
    HTML script are following style sheet rules. The following is sample
    which is used to create
    dynamic row.

    this.table = document.getElementById(tableId);
    currentTb = document.createElement("TBODY");
    currentRow = document.createElement("TR");
    currentCell = document.createElement("TD");
    currentElement = document.createTextNode("text");
    currentCell.appendChild(currentElement);
    currentElement = document.createElement("input");
    currentElement.setAttribute("type", "text");
    currentElement.setAttribute("name", "textBoxName");
    currentElement.setAttribute("id", "textBoxId");
    currentElement.setAttribute("size", "8");
    currentCell.appendChild(currentElement);
    currentElement = document.createElement("input");
    currentElement.setAttribute("type", "checkbox");
    currentElement.setAttribute("name", "checkBoxName");
    currentElement.setAttribute("id", "checkBoxId");
    currentElement.setAttribute("value", "t");
    currentCell.appendChild(currentElement);
    currentRow.appendChild(currentCell);
    currentTb.appendChild(currentRow);
    this.table.appendChild(currentTb);

    Sorry for long mail

    Thanks in advance
    Raghuram Banda
    Raghuram Banda, Nov 7, 2003
    #1
    1. Advertising

  2. Raghuram Banda

    kaeli Guest

    Re: Dynamically created rows in table are not following the StyleSheet rules

    And on the day Fri, 07 Nov 2003 05:31:10 GMT,
    enlightened us with <y6Gqb.2047$g4.45509
    @news2.nokia.com>...
    > Hi all,
    >
    > I've created a table with Table Header and the table may or may not
    > contain any rows initially.
    > I've included a .css file in <head> section of my HTML script and I'm
    > creating rows to the table
    > dynamically using JavaScript (using DOM), and the problem is those
    > created bby DOM are not
    > following style sheet rules applicable for table rows and cells. But the
    > rows created from within
    > HTML script are following style sheet rules. The following is sample
    > which is used to create
    > dynamic row.
    >


    currentTb = document.createElement("TBODY");

    If the table is already created, this might be mucking things up. I'm
    not sure, but try creating the tbody with the table header instead of
    via script. This might somehow be creating a second tbody.

    Just a thought.


    --
    --------------------------------------------------
    ~kaeli~
    Winerr 01C - Wrong Disk Formatted. Sorry About That.
    Winerr 01D - Enter any 11-digit prime number to continue.
    http://www.ipwebdesign.net/wildAtHeart/
    http://www.ipwebdesign.net/kaelisSpace/
    ------------------------------------------------
    kaeli, Nov 7, 2003
    #2
    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,226
    Subba Rao via DotNetMonster.com
    Mar 19, 2005
  2. Arjen Hoekstra
    Replies:
    0
    Views:
    551
    Arjen Hoekstra
    Aug 2, 2005
  3. Rio
    Replies:
    4
    Views:
    1,184
  4. msimmons
    Replies:
    0
    Views:
    472
    msimmons
    Jul 16, 2009
  5. T.G.
    Replies:
    2
    Views:
    1,067
Loading...

Share This Page