Creation of dynamic table

1

I'm creating a table with js

for (j = 0; j < usersConCaptura.length; j++) {
            html += "<tr>";
            let contador = 0;
            html += "<td id=usersConCaptura[j].ID_U>" + usersConCaptura[j].ID_U + "</td>";

I need to put as id the value of usersConCaptura[j] but do not put it, how do I solve it?

    
asked by hubman 07.09.2018 в 07:07
source

1 answer

1

For the information you give, I assume that your problem is that you are not concatenating the id, but you are putting the name of your variable as a string.

To fix it, you should concatenate, just like you do for content within <td>

Therefore, something like this would be

for (j = 0; j < usersConCaptura.length; j++) {
    html += '<tr>';
    let contador = 0;
    html += '<td id="' + usersConCaptura[j].ID_U + '">' + usersConCaptura[j].ID_U + '</td>';

Greetings

    
answered by 07.09.2018 / 07:14
source