Delete Alert before posting in HTML form using Javascript

Delete Alert

The Scenerio

HTML form with delete button(s). you want a delete alert (an alert to confirm delete before posting back to server).

The Solution

<form method="post" onsubmit="return (confirm('do you really want to delete this stuff?'));"> <input type="image" name="deleteitem" src="images/x.png"> </form>

and that’s all the trick!

in many cases, you would have more than one input on your form, just use multiple forms like this:

<form method="post" onsubmit="return (confirm('do you really want to delete this stuff?'));"> <input type="image" name="deleteitem" src="images/x.png"> </form>

<form method="post"> . . </form>

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.