...

View Full Version : can't use getElementById on <tbody> in IE



sosuke
03-23-2006, 05:44 AM
I can't use getElementById on <tbody> in IE for some reason, anyone know why? I have also tried:

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:

<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:

function printTable(result) {
document.getElementById("workshopQueryContent").innerHTML = result;
setMessage("Complete!");
}

Kor
03-23-2006, 07:40 AM
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]

sosuke
03-23-2006, 02:45 PM
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

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?

Kravvitz
03-23-2006, 04:32 PM
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/author/dhtml/reference/properties/innerhtml.asp

http://msdn.microsoft.com/workshop/author/tables/buildtables.asp



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum