www.webdeveloper.com
Results 1 to 5 of 5

Thread: Changing table content with IE

  1. #1
    Join Date
    Oct 2008
    Posts
    2

    Changing table content with IE

    Hi all,
    I want to dynamically replace the contents of an HTML table with Javascript. The following code works fine in FF but does not in IE...

    <script>
    function changeText(){
    document.getElementById('table').innerHTML = '<tr><td>new text</td></tr> ';
    }
    </script>


    <table id="table">
    <tr>
    <td>Old Text
    </td>
    </tr>
    </table>

    I think IE has a problem with getting the table, it says "Object not found".

    Any suggestions on making this work or any other way to change the table content.

    Thanks in advance for any help.

  2. #2
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,773
    Do you have more than one id="table" in your HTML document? Do you have a different tag with name="table" in the HTML document? If you answered yes to any of these questions, make sure you have only one id="table" and that no two tags have the same Id or name.

  3. #3
    Join Date
    Oct 2008
    Posts
    2
    Quote Originally Posted by toicontien View Post
    Do you have more than one id="table" in your HTML document? Do you have a different tag with name="table" in the HTML document? If you answered yes to any of these questions, make sure you have only one id="table" and that no two tags have the same Id or name.
    I have only one element with id="table".

  4. #4
    Join Date
    Feb 2003
    Location
    Michigan, USA
    Posts
    5,773

  5. #5
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Internet Explorer doesn't allow you to use innerHTML with parts of tables. If you want to access something that involves any parts of a table with innerHTML in IE you have to access the entire table including the table tag.
    Stephen

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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



Recent Articles