Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:00:40+00:00 2026-06-11T06:00:40+00:00

I have a function for adding a new row into a table but since

  • 0

I have a function for adding a new row into a table but since i have lots of inner nodes for each td (with lots of attributes for each node) I am just changing the .innerHTML of the row.

However this is causing problems to other functions because the #text node is not inserted.

I’ve tried adding a <text/> tag but that didnt do it..So..any suggestions?

My javascript code is:

var newTrNode = document.createElement('tr');
newTrNode.setAttribute('id', resultArray[0]);

var putInside = '<td><text/><input readonly="readonly" value="'+assetName+'" type="text"  class="field left"/></td><td><input type="text" value="credentials" class="field left" readonly="readonly" /></td><td>';
var rowNode = but.parentNode.parentNode;                                                                    
putInside += rowNode.childNodes[5].innerHTML;
putInside += '</optgroup></select></td><td><input type="text" value="'+resultArray[1]+'" class="field left" readonly="readonly" /></td><td><input type="password" value="'+resultArray[2]+'" class="field left" readonly="readonly" /></td><td><input onClick="editField('+resultArray[0]+',this)"type="button" value="Edit" class="field left"/><input onClick="deleteAsset('+resultArray[0]+')" type="button" value="Delete" class="field left"/><input onClick="lockUnlock('+resultArray[0]+',this, false)" type="button" value="Unlock" class="field left"/><img src="lock.png"/></td>';
newTrNode.innerHTML = putInside;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:00:41+00:00Added an answer on June 11, 2026 at 6:00 am

    Don’t use innerHTML to modify the content of a table row (or any part of a table) as it is specified to fail in at least some versions of IE. Use DOM methods. You can use innerHTML for an entire table or the content of cells (TD elements).

    There is no text element in HTML, browsers will create text nodes for text in the document. You can create text nodes using the createTextNode method of the document interface:

    var textNode = document.createTextNode('text');
    

    You can add rows using innerHTML with a function like:

    <script type="text/javascript">
    
    function rowsFromMarkup(table, markup) {
      var div = document.createElement('div');
      div.innerHTML = '<table>' + markup + '<\/table>';
      var rows = div.getElementsByTagName('tr');
      var tbody = table.tBodies[0];
    
      for (var i=0, iLen=rows.length; i<iLen; i++) {
        tbody.appendChild(rows[i]);
      }
    }
    </script>
    
    <table id="t0">
     <thead>
      <tr>
        <th>index
        <th>item
     </thead>
     <tbody>
      <tr>
       <td>0
       <td>foo
     </tbody
    </table>
    
    <button onclick="
     rowsFromMarkup(document.getElementById('t0'),'<tr><td>1<td>bar');
    ">Add a row</button>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to animate a table row sliding up, then adding a new
I have a table called newDataTable where I am adding new rows dynamically with
I have a jqGrid that I am adding a new row to that the
I have function LoadTempMovieList(), and need to load movies from sessionStorage. But it seems
I have function: char *zap(char *ar) { char pie[100] = INSERT INTO test (nazwa,
I have a table in which I am adding some rows dynamically and in
I have the following code for adding buttons in ever row of a DataGrid:
I am performing an insertion of a new row from an ASP form into
i have table with 4 rows and when i click on any row then
I have a table with four columns. I'm adding rows to the table dynamically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.