Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question can't use getElementById on <tbody> in IE

    I can't use getElementById on <tbody> in IE for some reason, anyone know why? I have also tried:
    Code:
    document.getElementsByTagName("tbody").item(0);
    does anyone know a slick way to add content to a existing table? i am passing <tr> blocks back from php to javascript using sajax.

    it works perfect in firefox

    the reason why i don't pass the entire tab back each time is because each of the columns is sortable

    here is my table:
    Code:
    <div id="datExample">
    <table class="dynatab" id="workshopQueryTable" border="0">
    <tr>
       <th>&nbsp;</th>
       <th>&nbsp;</th>
       <th>&nbsp;</th>
       <th colspan="2" align="center"><font style="font-size:.8em !important; text-align:center">Times are in 24 hour format.</font></th>
      <th colspan="6"> </th>
    </tr>
    <tr class="yellow" id="workshopQueryHeader">
       <th>Delete</th>
       <th>RO</th>
      <th class="sortable">Date</th>
      <th class="sortable">Start&nbsp;Time</th>
      <th class="sortable">End&nbsp;Time</th>
      <th class="sortable">Venue</th>
      <th class="sortable">Address</th>
      <th class="sortable">City</th>
      <th class="sortable">State</th>
      <th class="sortable">Zip</th>
      <th class="sortable">ID</th>
    </tr>
    <tbody id="workshopQueryContent">
    </tbody>
    </table>
    </div>
    here is the javascript that works in mozilla but not IE:
    Code:
    function printTable(result) {
      document.getElementById("workshopQueryContent").innerHTML = result;
      setMessage("Complete!");
    }

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    TBODY is a requested table's element in javascript, so that it will vitually exists even it is not HTML written. So that in fact your TBODY is the second one in the table, not the first. Try:

    document.getElemenById('workshopQueryTable').getElementsByTagName('tbody')[1]
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New Coder
    Join Date
    Nov 2004
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so now I know I am sitting in the right place with your code, IE recognizes I am on the right tag in the HTML
    Code:
    document.getElementsByTagName('tbody')[1].getAttribute("id");
    returns workshopQueryContent

    but it still will not take a .innerHTML in IE, in firefox once again it loads beautifully, any ideas?

  • #4
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The property is read/write for all objects except the following, for which it is read-only: COL, COLGROUP, FRAMESET, HTML, STYLE, TABLE, TBODY, TFOOT, THEAD, TITLE, TR.
    http://msdn.microsoft.com/workshop/a.../innerhtml.asp

    http://msdn.microsoft.com/workshop/a...uildtables.asp
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •