html弄多个按钮_HTML表单上的多个提交按钮 - 将一个按钮指定为默认按钮

bd96500e110b49cbb3cd949968f18be7.png

I have a form that has three submit buttons as follows:

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.

解决方案

My suggestion is don't fight this behaviour. You can effectively alter the order using floats. For example:

with:

#buttons { overflow: hidden; }

#buttons input { float: right; }

will effectively reverse the order and thus the "Next" button will be the value triggered by hitting enter.

This kind of technique will cover many circumstances without having to resort to more hacky Javascript methods.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值