Answer the question
In order to leave comments, you need to log in
How to substitute the post ID in the modal window?
Good day.
I have a list of records that are pulled from a db.
Each entry has
<a class="delobj" href="handlers/delete_object.php?id_obj=13220" data-obj="13220"><img src="/img/icon_delete_object.png"></a>
a link leading to a handler that deletes a record from the database using the GET method. <div class="modal fade" id="default-example-modal-sm-center" tabindex="-1" role="dialog" style="display: none;" aria-hidden="true">
<div class="modal-dialog modal-sm modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Вы точно хотите удалить запись?</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true"><i class="fal fa-times"></i></span>
</button>
</div>
<div class="modal-body">
текст сообщения
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect waves-themed" data-dismiss="modal">Отмена</button>
<button type="button" class="btn btn-primary waves-effect waves-themed">Удалить запись</button>
</div>
</div>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
<a class="delobj" href="javascript:void(0)" data-obj="13220">
<img src="/img/icon_delete_object.png">
</a>
function($){
$('.delobj').on('click', function(){
if(confirm('Sure?')) {
window.location.href = 'handlers/delete_object.php?id_obj=' + $(this).attr('data-obj')
}
})
}(jQuery)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question