问题描述
我有一个包含三个提交按钮的表单,如下所示:
I have a form that has three submit buttons as follows:
<input type="submit" name="COMMAND" value="‹ Prev">
<input type="submit" name="COMMAND" value="Save">
<input type="reset" name="NOTHING" value="Reset">
<input type="submit" name="COMMAND" value="Next ›">
<input type="button" name="NOTHING" value="Skip ›" onclick="location = 'yada-yada.asp';">
按钮行是提交,重置和javascript按钮的混合。按钮的顺序可以改变,但是在任何情况下,保存按钮保持在上一个和下一个按钮之间。这里的问题是当用户点击输入提交表单时,后变量COMMAND包含Prev;正常,因为这是表单上的第一个提交按钮。然而,我想要当用户通过输入按钮提交表单时触发下一步按钮。
The row of buttons is a mix of submit, reset and javascript buttons. The order of buttons is subject to change but in any case the save button remains between prev and next buttons. The problem here is that when a user hits "enter" to submit the form, the post variable "COMMAND" contains "Prev"; normal, as this is the first submit button on the form. I however want the "Next" button to be triggered when the user submits the form via enter button. Kind of like setting it as the default submit button, even though there are other buttons before it.
推荐答案
我的建议是不建议提交按钮, t打这个行为。您可以使用浮动有效地更改顺序。例如:
My suggestion is don't fight this behaviour. You can effectively alter the order using floats. For example:
<p id="buttons">
<input type="submit" name="next" value="Next">
<input type="submit" name="prev" value="Previous">
</p>
其中:
#buttons { overflow: hidden; }
#buttons input { float: right; }
将有效地颠倒顺序,因此下一步按钮将是通过敲击enter 。
will effectively reverse the order and thus the "Next" button will be the value triggered by hitting enter.
这种技术将覆盖许多情况,而不必求助于更复杂的Javascript方法。
This kind of technique will cover many circumstances without having to resort to more hacky Javascript methods.
这篇关于HTML表单上的多个提交按钮 - 将一个按钮指定为默认按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!