BrownChiLD
BrownChiLD

Reputation: 3723

Trying to output a loop of rows inside a table via Jquery and a target div tag

I have an HTML table, I have wrapped a div tag around 1 of the rows, so that jQuery can replace that w/ row/rows from my PHP output..

Here's what that table looks like in code (easier to view here):

http://d.pr/i/QzfH

My jQ loads

$("#points_details_data").load("points_view.php?eid=<?php echo $eid;?>");

and PHP outputs this actual code:

<tr><td bgcolor='#FFFFFF'>&nbsp;</td>
    <td bgcolor='#FFFFFF'>test</td>
    <td align='right' bgcolor='#FFFFFF'>- 100</td>
</tr>

but the resulting display/render is that the PHP output is outside of the target div..see here for screenshot of the actual output:

http://d.pr/i/eZYP

I have a feeling I can't div target inside tables.. can I?

Upvotes: 0

Views: 118

Answers (2)

Darryldecode
Darryldecode

Reputation: 553

Put your <div> tags inside your <td> tags..

then you can use:

var id = <?php echo $eid;?>;

document.getElementById("points_details_data").innerHTML = id;

Upvotes: 0

3coins
3coins

Reputation: 1342

You can't have a div around a tr tag. You can instead put that id on the tr and use something like this.

$.get("points_view.php?eid=<?php echo $eid;?>", function(data){
    $("#points_details_data").after(data);
});

A better solution would be to have thead, tbody and tfoot tags to wrap table head, body and footer and putting the id on the table. Then the ajax call will change to

$.get("points_view.php?eid=<?php echo $eid;?>", function(data){
    $("#points_details_data tbody").append(data);
});

Upvotes: 2

Related Questions