html – 如果在同一表单上有多个提交按钮,如何使用onsubmit()显示确认?

前端之家收集整理的这篇文章主要介绍了html – 如果在同一表单上有多个提交按钮,如何使用onsubmit()显示确认?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<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' />

用户点击第二个提交按钮,即不想我将确认对话框显示为“您确定要提交交易吗?”

解决方法

<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>

工作得很好.刚刚将onsubmit()更改为onclick().因为在这种情况下两者的功能是相同的.

原文链接:https://www.f2er.com/html/228261.html

猜你在找的HTML相关文章