In this code, I have multiple checkboxes i.e. name="recruiter_id"
with multiple submit button. Now, What happens when I click on the first row submit button it alert data but when I click on the last row submit button then it shows wrong recruiter_id
I don't know why? So, How can I get different recruiter_id
onclick
different submit button? Please help me.
<?php
foreach($wishlist as $row)
{
?>
<tr>
<td>
<input type="checkbox" name="recruiter_id" value="<?php echo $row['rid']; ?>" class="recruiter_id">
</td>
<td>
<input type="submit" id="<?php echo $row['job_id']; ?>" class="btn btn-danger job_id" value="Assign" />
</td>
</tr>
<?php
}
?>
<script>
$(document).ready(function() {
$(".job_id").click(function(e){
e.preventDefault();
job_id = this.id;
recruiter_id = $("input[name='recruiter_id']:checked").val();
alert(job_id);
alert(recruiter_id);
});
});
</script>