![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiZpdmLwV3LcNXZnFWbp9CXt92YuI2bv5Wdy5yd3d3Lc9CX6MHc0RHaiojIsJye.gif)
HTML <input> 标簽
第二個送出按鈕覆寫了表單的 HTTP 方法:
<form action="demo-form.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="送出">
<input type="submit" formmethod="post" formaction="demo-post.php" value="使用 POST 送出">
</form>
Internet Explorer 10、Firefox、Opera、Chrome 和 Safari 支援 formmethod 屬性。
注意:Internet Explorer 9 及之前的版本不支援 <input> 标簽的 formmethod 屬性。
formmethod 屬性定義發送表單資料到 action URL 的 HTTP 方法。
formmethod 屬性覆寫 <form> 元素的 method 屬性。
<b>注意:</b>formmethod 屬性與 type="submit" 和 type="image" 配合使用。
表單資料可被作為 URL 變量的形式來發送(method="get")或者作為 HTTP post 事務的形式來發送(method="post")。
<b>關于 "get" 方法的注釋:</b>
該方法将表單資料以名稱/值對的形式附加到 URL 中
該方法對于使用者希望加入書簽的表單送出很有用
URL 的長度是有限的(不同浏覽器限制不一樣),是以,您不能确定是否所有的表單資料都能被正确傳輸
絕不要使用 "get" 方法來發送敏感資料!(比如密碼或者其他敏感資訊,在浏覽器的位址欄中是可見的)、
<b>關于 "post" 方法的注釋:</b>
該方法将表單資料以 HTTP post 事務的形式發送
通過 "post" 方法送出的表單不能加入書簽
"post" 方法比 "get" 更安全,且 "post" 沒有長度限制
formmethod 屬性是 HTML5 中的新屬性。
<input formmethod="get|post">
值
描述
get
預設。将表單資料(form-data)以名稱/值對的形式附加到 URL:URL?name=value&name=value。
post
以 HTTP post 事務的形式發送表單資料(form-data)。
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIiZpdmLwV3LcNXZnFWbp9CXt92YuI2bv5Wdy5yd3d3Lc9CX6MHc0RHaiojIsJye.gif)