tags:

views:

15

answers:

1

HI! I have a table, generated dynamic in jquery populated with data from a recordset. With a function I want to modify some cells from this table. How can I do that...? Thank you! Some code, maybe it helps:

    ....
for (i = 0; i < nrInreg; i++) {
    $("<tr>").append('<table id="bod'+ i +'" >'+ headerTura +
 '<tr class="planifVtabel">' + 
 '<td class="celulaCO">' + ptAfisare.data[i].Cod +'</td>'+
        '<td style="width:170px; text-align:left;">' + '&nbsp;' + ptAfisare.data[i].Nume + '&nbsp;' + ptAfisare.data[i].Initiala + '. ' + ptAfisare.data[i].Prenume +
        '</td>' + 
        '<td class="celulaCO">' + Zstart[11] + Zstop[11] +'</td>' +
 '</tr></table></tr>').appendTo("#listaMea");
}
....

I want a function to modify some td like putting new Zstart[11] and Zstop[11], in the same cell.

+1  A: 

Give each td an ID which depends on some data in the recordset. One solution could be to store the primary key in the tr and then use

var locator = "#" + id + " td:nth-child(" + columnIndex + ")";
$(locator).text('new text')

to locate and modify a specific cell.

Aaron Digulla
I used $('table tbody tr#' + ptAfisare.data[i].Id_Titular).children("td:nth-child(" + colIndex + ")").text('new text');"td[" + columnIndex + "]" seems not working ..Thank you for your answer.
braveheartvd
Sorry for that; [] selects attributes. My new answer should work. There is no need for "table tbody tr" if you use "#" (an ID must be unique for the whole page).
Aaron Digulla
Thank you Aaron!
braveheartvd