I have the following code which prints the values in a datatable.
<?php
foreach ($result as $val) {
?>
<input class="example" type="checkbox" value="yes" id="example" name="example"><?php echo $val->id; ?>
<?php } ?>
Now I want to send the value to the server when the checkbox is checked. I have the following code for the same, however I'm confused on how I can get the ID of the row which is echoed by PHP.
$(".example").change(function() {
var value = $('.example').attr('value');
console.log(value);
});
Thanks in advance.