RatDon RatDon - 6 months ago 23
HTML Question

How to use onsubmit() to show a confirmation if there are multiple submit buttons on the same form?

<form onsubmit="return confirm('Are you sure you want to rollback deletion of candidate table?')">
<input type='submit' name='delete' value='Undo' />
<input type='submit' name='no' value='No' />


when the user clicks on second submit button i.e
No
i want to display the confirmation dialogue as "Are you sure you want to commit the transaction."

Answer
<form method='post'>
    <input type='submit' name='undo' value='Undo' onclick="return confirm('Are you sure you want to rollback deletion of candidate table?')"/>
    <input type='submit' name='no' value='No' onclick="return confirm('Are you sure you want to commit delete and go back?')"/>
</form>

Worked fine. just changed onsubmit() to onclick(). as the function of both in this situation is same.