I have this table, from which i’d like to select all the td elements value if the checkbox is checked and then put all the elements in some array or string, so that i can transfer it to server side.
<table id="tableDg">
<tbody>
<tr>
<td><input type="checkbox" class = "chkbCsm" ></input></td>
<td width="10%" align="center"> <input type="hidden" id="nameText" readonly="true" value="{name}">{name}</input></td>
<td width="22%" align="center"> <input type="hidden" id="nameText" readonly="true" value="{host}">{host}</input></td>
</tr>
</tbody>
</table>
Here is what i am doing on jquery side, but it does the selecting thing irrespective of the checkbox being on. Please somebody help me get it in some array.
$('#tableDg tbody tr').live('click', function (event) {
$(this).find('td').each( function( index, item ) {
if ( $(this).has(':hidden') ) {
alert( $(this).find(':hidden').val() );
}
});
});
Added a jsFiddle link
Take a look here
1 Answer