The delete and edit button works only on the first 10 rows. This the program that I use. I can't figure it out.
This is the video of my problem: https://drive.google.com/file/d/1HRz3E4fcYRQhylWducFiqylwxK9Iy1Vl/view?usp=share_link
Below are the program that I am working on. When I am clicking the 11th row, it has no response even on console. It looks like the buttons have no functionality.
HTML
<td>
<button class="btn btn-success btn-sm edit btn-flat" data-id="<?php echo $row['empid']; ?>"> <i class="fa fa-edit"></i> Edit</button>
<button class="btn btn-danger btn-sm delete btn-flat" data-id="<?php echo $row['empid']; ?>"> <i class="fa fa-trash"></i> Delete</button>
</td>
<script>
$(function(){
$('.edit').click(function(e){
console.log("click edit")//DISPLAY IN CONSOLE
e.preventDefault();
$('#edit').modal('show');
var id = $(this).data('id');
getRow(id);
});
$('.delete').click(function(e){
console.log("click delete")//DISPLAY IN CONSOLE
e.preventDefault();
$('#delete').modal('show');
var id = $(this).data('id');
getRow(id);
});
$('.photo').click(function(e){
e.preventDefault();
var id = $(this).data('id');
getRow(id);
});
});
function getRow(id){
$.ajax({
type: 'POST',
url: 'employee_row.php',
data: {id:id},
dataType: 'json',
success: function(response){
$('.empid').val(response.empid);
$('.employee_id').html(response.employee_id);
$('.del_employee_name').html(response.firstname+' '+response.lastname);
$('#employee_name').html(response.firstname+' '+response.lastname);
$('#edit_firstname').val(response.firstname);
$('#edit_lastname').val(response.lastname);
$('#edit_address').val(response.address);
$('#datepicker_edit').val(response.birthdate);
$('#edit_contact').val(response.contact_info);
$('#gender_val').val(response.gender).html(response.gender);
$('#position_val').val(response.position_id).html(response.description);
$('#schedule_val').val(response.schedule_id).html(response.time_in+' - '+response.time_out);
$('#edit_fingerprint').html(response.FingerprintID);
$('#edit_status').val(response.status);
}
});
}
</script>