I am trying to retrieve data from specific rows in a table based on check box selection done by the user.
For this, I have found two methods eq(rowIndex) and nth-child(rowIndex). However,it works only when given an absolute values and not when its dynamic.
Have tried the following but no luck on this:
function getData()
{
var chkArr = document.getElementsByName('checkbox');
var checkedRecord = 0;
for(var i=0; i<chkArr.length; i++)
{
if(chkArr[i].checked)
{
checkedRecord = i;
$('#summaryTable > tbody > tr').eq('#checkedRecord').children('td').each(function(j)
//checkedRecord is the row index here
{
//fetch values from td
});
}
}
}
Here's how my html looks
<table>
<tr>
<td><input type="text" id="text1"></td>
<td>
<select>
<option value="opt1">Orange</option>
<option value="opt2">Green</option>
</select>
</td>
</tr>
<tr>..</tr>
Any suggestions on this?
>in selectoreq()takes a number, not a selector.td?