Using jQuery to delete a row in MySQL?
Hello,
I am new to jQuery am having a hard time coming up witha solution for the following. I have a table with a delete link at the end of every row. I use Bootstrap to create a modal to confirm the deletion and have jQuery delete the row. Unfortunately it is not working. All I get is the first row on any one page passed the unique id to my delete_item.php page via the jQuery. I have numerous hours reading up on jQuery and tried numerous examples but nothing works. I'm hoping someone here can. Here is the code
JS:
- <!--JavaScript for popup alert to Delete arow using Bootstrap modal
<script type="text/javascript">
$(document).ready(function(){
$(document).on('click', '#delete-row', function(e){
e.preventDefault();
var id = $("#delete-row").attr('data-id'); // get id from td element and store it in $id.
window.location = 'printer_delete.php?id=' + id; // call printer_delete.php with $id value to delete row.
});
});
</script>-->
PHP:
- echo "<td><a class='one glyphicon glyphicon-trash delete-row' id='delete-row' data-toggle='modal' data-placement='bottom' title='Delete Printer Record' href='#' data-target='#myModal' aria-hidden='true' data-id='" . $row['id'] . "'></a></td>";