0

是否可以submit在同一个 HTML 表单中定义两个按钮?

两个按钮将执行完全相同的功能..

但是,在给定时间只会显示一个.. 显示哪个取决于用户正在使用的设备(通过@media查询解决)..

按钮技术上两个提交按钮将在 HTML 中定义。这可能吗?

4

4 回答 4

1

You know you can actually use <button>'s in forms and they submit the form

<form action="">
    <button>Submit 1</button>
    <button>Submit 2</button>
</form>

Demo

This makes sense they are treated as submit buttons because you wouldn't have a button to take you somewhere or something while your filling out a form.

于 2013-07-18T10:30:58.100 回答
1

是的。但是,如果您不想 2 次提交输入,您可以创建按钮并设置 onclick javascript 处理程序以发送该表单。

于 2013-07-18T10:27:58.523 回答
1

CSS:

@media device1 { 
    #device2submitbutton { 
        display:none; 
    } 
}
@media device2 { 
    #device1submitbutton { 
        display:none; 
    }
}

HTML:

<input type="submit" id="device1submitbutton" value="device1 submit"/>
<input type="submit" id="device2submitbutton" value="device2 submit"/>
于 2013-07-18T10:28:23.367 回答
1
<form action="" method="get">
  <input type="submit" name="sb" value="One">
  <input type="submit" name="sb" value="Two">
  <input type="submit" name="sb" value="Three">
</form>

只需将其放在 HTML 页面中,单击按钮,然后查看 URL

于 2013-07-18T10:29:27.703 回答