Reputation: 5068
I am trying to populate an HTML table from data that is in a two-dimensional array. The data is coming to an $.ajax script from a php/MySQL query. I'm successfully parsing the data in the success function and I can read out the array element contents to the console, but I can't figure out why the values won't populate the HTML table.
See this jsFiddle for my work.
In the console I can populate the input in any of the table cells with this jQuery notation:
$('#tblApTdms tr:nth-child(4) td:nth-child(3) input').val('q34rfewa')
but it won't populate in the jsFiddle, in the Web application I'm building, nor in an isolated test page.
I must be missing something here!
Upvotes: 2
Views: 291
Reputation: 17441
You need to use parens:
$('#tblApTdms tr:nth-child(' + (r + 1) + ') td:nth-child(' + (c + 1) + ') input').val(note);
Without the parens, it thinks you're trying to append strings, since that is the prior context.
Upvotes: 1
Reputation: 7346
Try putting parenthesis around the addition equations:
$('#tblApTdms tr:nth-child(' + (r + 1) + ') td:nth-child(' + (c + 1) + ') input').val(note);
Upvotes: 3