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 632997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:08:13+00:00 2026-05-13T20:08:13+00:00

Why the following code doesn’t work? <html> <head> <script type=text/javascript> function addTable() { var

  • 0

Why the following code doesn’t work?

<html>
<head>
    <script type="text/javascript">
    function addTable() {
        var table = document.createElement('table');
        table.innerHTML = "<tr><td>123</td><td>456</td></tr>";
        document.getElementById("addtable").appendChild(table);
    }
    </script>
</head>
<body>
    <input type="submit" value="New Table" onClick="addTable()"/>
    <div id="addtable"></div>
</body>
</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-13T20:08:14+00:00Added an answer on May 13, 2026 at 8:08 pm

    To the best of my knowledge, setting the innerHTML property of a table element or table section element (like tbody or thead) does not work on Internet Explorer (EDIT: I just checked – with ietester and plain IE8. Result is “unknown runtime error” for IE6 and IE8, and it crashes IE7 but that might be an IEtester specific problem).

    The DOM standard way of adding rows to a table is using the insertRow() method on a table or table section element (look for HTMLTableElement and HTMLTableSectionElement in that DOM spec) :

    <script type="text/javascript">
    function addTable() {
        var c, r, t;
        t = document.createElement('table');
        r = t.insertRow(0); 
        c = r.insertCell(0);
        c.innerHTML = 123;
        c = r.insertCell(1);
        c.innerHTML = 456;
        document.getElementById("addtable").appendChild(t);
    }
    </script>
    

    In the script, there is no explicit table section being created. AFAIK, a TBODY is automatically created, and rows are inserted in there.

    EDIT: regarding IE, I should point out that you can add a table with content and all by setting the innerHTML property, but the html you inject in there must be a complete table. So this does work, even on IE:

    <script type="text/javascript">
    function addTable() {
        var html = "<table><tr><td>123</td><td>456</td></tr></table>";
        document.getElementById("addtable").innerHTML = html;
    }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 515k
  • Answers 515k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The code below is based on the proxy design pattern.… May 16, 2026 at 6:40 pm
  • Editorial Team
    Editorial Team added an answer The trick is to temporarily show it, measure the height,… May 16, 2026 at 6:40 pm
  • Editorial Team
    Editorial Team added an answer You probably don't need to separate the work into separate… May 16, 2026 at 6:40 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

The following code doesn't work. $(document).ready(function(){ $(#digitalchange).validate( { rules: { addbalance: { digits:true, min:20,
The following code doesn't work as I intuitively expect it to: function MyObject(input) {
Should the following code not work? $('.elastica').click(function(){ document.getElementById('bigimage').attr('src')= $(this).attr('src'); }); It doesn't change a
following code doesn't work with input: 2 7 add Elly 0888424242 add Elly 0883666666
The following code doesn't work! 'this' in in the context when i access it
The following code doesn't seem to get the correct count..... var materials = consRepository.FindAllMaterials().AsQueryable();
I tried the following code, but it doesn't work. How should it be modified?
The following code doesn't compile with gcc, but does with Visual Studio: template <typename
The following code doesn't compile ( error CS0123: No overload for 'System.Convert.ToString(object)' matches delegate
The following code doesn't compile for obvious reasons, namely that Foo is trying to

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.