用包含几个提交按钮的表单提交一个带有输入按钮的表单 [英] Submitting a form with the enter button in a form with several submit buttons

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

问题描述

我有一个带有简单文本字段和多个提交按钮的表单。当用户按下回车键时,我想提交具有特定提交按钮的表单,但它看起来像表单只是选择第一个按钮。有什么办法可以告诉浏览器在用户按下输入时选择哪个提交按钮?如果这是唯一的解决方案,最好不用javascript,但我会采取。

I have a form with a simple text field and multiple submit buttons. When the user presses enter, I want to submit the form with a specific submit button, but it looks like the form just chooses the first button instead. Is there any way to tell the browser which submit button to choose when user presses enter? Preferrably without javascript, but I'll take it if that's the only solution.

编辑:除了有多个提交按钮,我没有别的选择。这是一个传统的应用程序。

I have no other choice than having multiple submit buttons. This is a legacy app.

推荐答案

没有办法。最简单的解决方案就是确保表单中的第一个提交按钮是您想要由 Enter 按钮触发的按钮。

There's no way. The simplest solution is just to ensure that the first submit button in the form is the one you want triggered by the Enter button.

请注意,此提交按钮可以是表单中其他位置的按钮的副本,并且不必是可见的

Note that this submit button can be a duplicate of a button elsewhere in the form, and it doesn't have to be visible.

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

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