I can't retrieve the id of my form which is found in a PHP loop the last one between works but not the following ones
JavaScript
$(document).ready(function() {
$('#sendDelete').on('click',function(){
var id = $(this).data("id");
alert (id);
});
});
PHP
while ($last_data = $req_last_data->fetch(PDO::FETCH_ASSOC)){
$last_id = $last_data['id'];?>
<tr><?php
if (!empty($_SESSION['us_id']) && $_SESSION['us_idRang'] <= 2){?>
<td>
<form id="formDeleteQuantity-<?= htmlspecialchars($last_id, ENT_QUOTES, 'UTF-8');?>" method="post" action="../controller/deleteEnter.php" role="form">
<button type="button" id="sendDelete" class="btn btn-dark btn-index" value="delete" data-id ="<?= htmlspecialchars($last_id, ENT_QUOTES, 'UTF-8');?>">Supprimer</button>
</form>
</td><?php
}?>
</tr><?php
}