Re: Need help with JavaScript
Part of the problem is the HTML. Strictly speaking, you can't put a div into a table like that. You can put a div into a table cell, but you can't put only part of a table (a set of rows, for instance) into a div in a table.
In this case, you are using an ordinary table row as your table header, then trying to dynamically add rows. You can simplify that a whole bunch by using a real table header, then filling in the table body:
HTML Code:
<table id="table">
<thead>
<tr>
<th>#</th>
<th>Last Name, First Name</th>
<th>Specialty</th>
<th>Rank</th>
</tr>
</thead>
<tbody id="PHPHere">
</tbody>
</table>
I'm going to assume that this is a "dry run" for something that's going to be a bit more dynamic later (it makes no sense to use JavaScript to fill in the table on a page this way when you can directly write to the table at the server). You may find it works better all around if you use DOM methods to create a table row, create cells and their content, append the cells to the row, then append the row to the table -- if you do it that way, you can use JSON for the data transport layer so the information comes in as name:"value" pairs rather than sending an HTML-formatted document fragment. That will make it much easier to reuse the data in other ways (like in a pop-up details panel, for instance).
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)