...

View Full Version : Can't display a table row via Ajax



rfresh
07-31-2011, 07:08 PM
I'm trying to click on a link and via Ajax, get a table row to display updated data. I have it all working except it displays at the top of the table instead of inside the table at the desired row.

For now, I'm just trying to add a simple table row using:



<TR><TD>test</TD></TR>


Here is my table code:


<TABLE>
<TR><TD>one</TD></TR>
<TR><TD>two</TD></TR>
<span id="id_row3"></span>
</TABLE>


So when I click on my link to execute the ajax code, I expect to see a table row inserted with the text "four" but "four" displays at the top of the web page, above the table itself. How can I get the new row to insert at the id_row3 tag?

Thanks for any help...

devnull69
07-31-2011, 09:09 PM
1. Get rid off the span ... it is not allowed like this inside a table
2.


var newTR = document.createElement('tr');
var newTD = document.createElement('td');
var newText = document.createTextNode('test');
newTD.appendChild(newText);
newTR.appendChild(newTD);
document.getElementsByTagName('table')[0].getElementsByTagName('tbody')[0].appendChild(newTR);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum