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

  • SEARCH
  • Home
  • 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 6660293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:08:14+00:00 2026-05-26T02:08:14+00:00

I have a appendChild JS function that works beautifully in all the browsers except

  • 0

I have a appendChild JS function that works beautifully in all the browsers except IE.

I am using a JS array and appending this data to a table.

http://jsfiddle.net/2waZ2/51/ Has the code – and works fine in fiddle!

I have looked around the other answers and their problems seem to be a bit different to mine. Maybe I just need to make a tbody, but I dont really know how to do that.

Whats the best way to rewrite this to work in Ie?

Append code part as in the fiddle:

var row =  document.createElement('tr');
row.innerHTML = displayArrayAsTable(QR4, 24, 25);
document.getElementById('mytable').appendChild( row ) ; 

function displayArrayAsTable( array, from, to ) {
  var array = array || [],
  from = from || 0,
  to = to || 0;
 var html = '';

 if ( array.length < 1 )
{
  return;
}
if ( to == 0 )
{
    to = array.length - 1;
}
for ( var x = from; x < to + 1; x++ )
 {
html += '<td>' + array[x] + '</td>';
}
 return html;
}
  • 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-05-26T02:08:15+00:00Added an answer on May 26, 2026 at 2:08 am

    The best way would be to use insertRow [MDN]:

    var row = document.getElementById('mytable').insertRow(-1);
    row.innerHTML = displayArrayAsTable(QR4, 24, 25);
    

    As for tBody: Yes, that could be the problem. The browser always generates a tBody element, no matter whether it is specified in the HTML or not.
    Maybe you can solve your problem by just appending the new row to this tBody element:

    document.getElementById('mytable').tBodies[0].appendChild( row );
    

    But I remember reading that IE had problems with manipulating tables with normal DOM manipulation methods. Whether this applies in this case as well, I don’t know. insertRow should work in any case.

    Update: Indeed, it seems that IE does not like to append td elements with innerHTML either. A solution would be to pass row also as parameter to displayArrayAsTable and use insertCell [MDN] to create a new cell.

    Update 2: For example you can do it like this:

    for ( var x = from; x < to + 1; x++ )
    {
        var cell = row.insertCell(-1);
        cell.innerHTML = array[x];
    }
    

    where row is a fourth parameter of the function and called as:

    var row = document.getElementById('mytable').insertRow(-1);
    displayArrayAsTable(QR4, 24, 25, row);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html table that pulls data from a DB. It has an
I'm having a problem with this jQuery function, the portion of the function that
I have this set of code that adds a display:none css class to a
I have a dilemma that goes like this. I have a string that represents
I need your help. This works so far that I will get alerts when
I have a function that if called, includes a js file and uses an
I have a Greasemonkey script that works just fine in Firefox and Opera. I
I have found a javascript function that inverts colors on webpage: String javascript =
If I have a var t = document.createTextNode(text) parent.appendChild(t); Is it possible to simply
I have the following javascript: css = document.createElement('style'); css.setAttribute('type', 'text/css'); css_data = document.createTextNode(''); css.appendChild(css_data);

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.