第二个提交按钮覆盖了表单的 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 属性。
注意:formmethod 属性与 type="submit" 和 type="image" 配合使用。
表单数据可被作为 URL 变量的形式来发送(method="get")或者作为 HTTP post 事务的形式来发送(method="post")。
关于 "get" 方法的注释:
关于 "post" 方法的注释:
formmethod 属性是 HTML5 中的新属性。
< input formmethod = "get|post" > |
值 | 描述 |
---|---|
get | 默认。将表单数据(form-data)以名称/值对的形式附加到 URL:URL?name=value&name=value。 |
post | 以 HTTP post 事务的形式发送表单数据(form-data)。 |
在线实例
字符集 & 工具
最新更新
站点信息
关注我们