按钮不提交表单而是提交值

时间:2019-02-14 22:41:50

标签: html node.js button

我想要一个不提交表单但提交值的按钮。例如,

Jan 14 00:00:02 server.host.com MSWinEventLog    5       Security        22159648        Sun Jan 13 23:59:35 2019        4634    Microsoft-Windows-Security-Auditing             N/A     Audit Success   server.host.com  12545   An account was logged off. Subject: Security ID:            S-1-5-21-3015042641-2194367929-112691256-2051 Account Name:           SVCACCT Account Domain:         MYDOMAIN Logon ID:               0xD7FC64F5 Logon Type:                     3 This event is generated when a logon session is destroyed. It may be positively correlated with a logon event using the Logon ID value. Logon IDs are only unique between reboots on the same computer.

Jan 14 00:00:02 server.host.com MSWinEventLog    5       Security        22159648        Sun Jan 13 23:59:35 2019        4634    Microsoft-Windows-Security-Auditing             N/A     Audit Success   server.host.com  12545   An account was logged off. Subject: Security ID:            S-1-5-21-3015042641-2194367929-112691256-2051 Account Name:           SVCACCT2 Account Domain:         MYDOMAIN Logon ID:               0xD7FC64F5 Logon Type:                     3 This event is generated when a logon session is destroyed. It may be positively correlated with a logon event using the Logon ID value. Logon IDs are only unique between reboots on the same computer.

当我按第一个时,它不会提交表格,但是会提交其值。在node.js中,我将拥有。

<html>
 <body>
  <form action="/home" method="post">
   <button value="1" type="button" name="b1>Test</button>
   <button value="2" type="submit" name="b2">Test2</button>
  </form>
 </body>
</html>

当我按下button1时,它不会提交任何内容,也不会重定向您。当您按下button2时,它将重定向您,并会console.log记录button1和button2。

1 个答案:

答案 0 :(得分:0)

也许隐藏的输入可以做到?

 <input value="1" type="hidden" name="b1>