yihong0618 和朋友们的频道 头像

消息来源频道

yihong0618 和朋友们的频道

@hyi0618

频道8,612 位成员公开可见0 人在线

yihong0618 和朋友们的频道

成员规模8,612 位成员
在线情况0 人在线
消息总数10,129 条消息
浏览量总数3,286,989 次浏览

在这个频道里搜索消息……

t.me/hyi0618

TIL:
Link: https://github.com/jbranchaud/til/blob/master/html/determine-which-button-submitted-the-form.md
📌 Determine Which Button Submitted The Form
It is pretty common for a form to have a singular submit button. If the user
clicks 'Submit', then the form fires a POST off to the server, the server can
process the request, and that's it.
But what about a form that has two or more buttons? For instance, imagine some
kind of consent form where the user needs to either Accept or Reject some
terms.
Just like other inputs, the <button> tag.
<form action="/terms" method="post">
<p>Something about the terms ...</p>
<div>
<label for="name">Email: </label>
<input type="email" name="email" id="email" required>
</div>
<div>
<button type="submit" name="commit" value="accept">Accept</button>
<button type="submit" name="commit" value="reject">Reject</button>
</div>
</form>
In addition to the email attribute, when the user submits the form, it will
include a commit attribute that has a value of either 'accept' or
'reject'.
Naming it commit is a convention I'm.
You can name it whatever makes sense to you.