i have a table in which data populating dynamically from db, now there is a checkbox on start of each row,what i want to do is when the user clicks on export button i want to get all those rows which are checked, this is my code!
Dyanamic Table
<table id="example" class="export_table">
<thead>
<tr>
<th id="not1">Check Box</th>
<th>Brand</th>
<th>Production Date</th>
<th>Expiry Date</th>
<th>Made In</th>
<th>Status</th>
<th>Batch Code</th>
<th>Created On</th>
</tr>
</thead>
<tbody>
$i=0;
foreach($results as $r){
echo "<tr>";
echo "<th id='not2'><input type='checkbox' name='checkedvalues' value='val_".$i."'/> </th>";
echo "<td>".$r['brand']."</td>";
echo "<td>".$r['production_date']."</td>";
echo "<td>".$r['expiry_date']."</td>";
echo "<td>".$r['madein']."</td>";
echo "<td>".$r['status']."</td>";
echo "<td id='main-print'>".$r['batch_code']."</td>";
echo "<td>".$r['created_on']."</td>";
echo "</tr>";
$i++;
}
?>
</tbody>
</table>
JQuery
$(document).ready(function() {
$("#export").click(function(){
var selectedvalues = [];
$.each($("input[name='checkedvalues']:checked"), function(){
selectedvalues.push($(this).val());
});
alert("Checked values are: " + selectedvalues.join(", "));
});
});
now i am getting only the values of selected checkbox which infact i dont want what i want is to generate an array which should be populated on the basis of checked attributes! it should take the full row on the basis of which checkbox is checked and then return me an array with all rows which are checked, any help?