亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在帶有標簽的一個表單中使用多個提交按鈕?

在帶有標簽的一個表單中使用多個提交按鈕?

Go
汪汪一只貓 2023-08-21 16:36:38
我正在使用帶有標簽的提交按鈕。然而,還需要使用一個按鈕。我可以在一個表單中使用兩個帶有標簽的提交按鈕嗎?<div>    ...    <form id="action-1" action='my action1 html' method="post">        <input class="mini-action" type="text" name="mini" value="1">    </form></div><div class="details">    // A tag submit button currently in use    <a title="action1" href="#" onclick="document.getElementById('action-1').submit()">action-1</a></div><div class="details">    // ToDo: Here I want to send to action2 url when submit button is clicked.    <a title="action2" href="#" onclick="document.getElementById('action-2').submit()">action-2</a></div>
查看完整描述

1 回答

?
一只斗牛犬

TA貢獻1784條經驗 獲得超2個贊

您使用的標簽不是提交按鈕,而是被劫持以充當按鈕的鏈接,此外,將提交按鈕放置在它們提交的表單中被認為是最佳實踐。


您可以使用屬性覆蓋提交按鈕的操作formaction


<form action="action-1">

  <!-- input fields go here -->

  <button type="submit">this will trigger action-1</button>

  <button type="submit" formaction="action-2">this will trigger action-2</button>

</form>


查看完整回答
反對 回復 2023-08-21
  • 1 回答
  • 0 關注
  • 178 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號