如何使用onsubmit()在同一表单上有多个提交按钮时显示确认? [英] How to use onsubmit() to show a confirmation if there are multiple submit buttons on the same form?
本文介绍了如何使用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' />
当用户点击第二个提交按钮时,即否
我想将确认对话框显示为您确定要提交交易吗?。
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."
推荐答案
<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()
。因为在这种情况下两者的功能是相同的。
Worked fine.
just changed onsubmit()
to onclick()
. as the function of both in this situation is same.
这篇关于如何使用onsubmit()在同一表单上有多个提交按钮时显示确认?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文