Confirmation dialog before deleting data - Javascript, PHP

preview_player
Показать описание
Confirmation dialog before deleting data - Javascript, PHP

In this tutorial, we are going to teach you how you can show a confirmation dialog before deleting any data. Suppose you are displaying a lot of data in tabular form in the admin panel, and you have a delete button at the end of each row. Now when someone clicks on it, you may be submitting a form with POST request or redirecting to a page where that data will be deleted. But what if someone accidentally clicks on any row, or clicks the wrong row? Then that row will be deleted from the database.

As we know that today almost every website is using Bootstrap and your project will also be using a large portion of the Bootstrap framework. So we are going to use Bootstrap to display a confirmation dialog. In Bootstrap, they are called "modal".

What we are going to do is to show heading in modal-header div, and create a form in modal-body div, in this form we will create a hidden input field which will be the unique ID of the row which needs to be deleted from the database. Set the form action attribute to the page where you will handle to perform the delete action. In modal-footer, we will simply create a submit button which will be linked with that form using form attribute. Make sure the form attribute on the submit button will be the same as the form id attribute.

Source files:
Рекомендации по теме
Комментарии
Автор

Thank you for this effort. You just saved me over 24hrs of troubleshooting. Kudos

MichaelAdenson
Автор

You are awesome ❤ Thanks for teaching us ❤

compScientizt
Автор

Thank you so much for your video. Among other video, your script are working for me. Saved my day.

harithm
Автор

Thank you so much for this video. It solved my problem.

apurvapatre
Автор

Hi, can you show the delete-user.php, please?

inazhivkova
Автор

i have a problem in onclick function "

jenniferb.maducdoc
join shbcf.ru