This might be a trivial question, but I am a bit confused how to extract column data & construct an object.
The table is dynamic in nature, generated based on the data provided.
The format is like this
<tr>
<td> Label </td>
<td>
<input type = "radio" value="yes"/> YES
<input type = "radio" value="no"/> NO
<textarea>
</td>
<td>
<input type = "radio" value="yes"/> YES
<input type = "radio" value="no"/> NO
<textarea>
</td>
// This structure can repeat
...
...
</tr>
// Rows will repeat themselves
I have jotted up this so far
$(function () {
$('#submit').click(function () {
var i = 0;
var t = document.getElementById('table');
$("#table tr").each(function () {
var columns = $(this).find('td');
/* how to extract column data here?, so that I construct
a column object and keep looping for the other columns
});
});
My JSON needs to be like this: [{label:data, isPresent:data, value:data}, {..}, {..}]
I am unable to get the data of both columns () in one go and then loop over the next 2 columns.