我正在使用帶有標簽的提交按鈕。然而,還需要使用一個按鈕。我可以在一個表單中使用兩個帶有標簽的提交按鈕嗎?<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>
- 1 回答
- 0 關注
- 178 瀏覽
添加回答
舉報
0/150
提交
取消