Javascript onsubmit与带有多个提交按钮的表单 [英] Javascript onsubmit with form with multiple submits buttons

查看:80
本文介绍了Javascript onsubmit与带有多个提交按钮的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有两个提交按钮的表单,一个名为'display',另一个名为'disenrol'。显示提交不需要确认,而另一个确实。最初我打算使用

I have a form with two submits buttons, one called 'display' and the other called 'disenrol'. The display submit doesn't need confirmation whereas the other does. Originally I was going to use

onsubmit="return confirm('Are you sure you want to remove the modules?');"

但当然这不会起作用,因为它会对两个提交做出反应。有没有办法可以指定哪些提交应该值得? (我对javascript很新,所以请温柔地对待我)

But of course that won't work because it reacts to both of the submits. Is there a way I can specify which submit it should worth with? (I'm quite new to javascript so please be gentle with me)

谢谢

推荐答案

试试这个:

<input type="submit" onclick="return confirm('Are you sure you want to remove the modules?');" value="submit1" />

这篇关于Javascript onsubmit与带有多个提交按钮的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆