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>

 

Development Specialist, Artist and Activist
Personal Website

Leave a Reply

Your email address will not be published.

*