Latest web development tutorials

HTML button formaction property

HTML button labels Reference Manual HTML <button> tag

Examples

Submit a form with two buttons (with a different action), first submit button to submit the form data to "demo_form.html", the second submit button to submit the form data to "demo_admin.html":

<form action="demo_form.html" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<button type="submit">提交</button><br>
<button type="submit" formaction="demo_admin.html">提交</button>
</form>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 10, Firefox, Opera, Chrome, and Safari support formaction property.

Note: Internet Explorer 9 and earlier versions do not support IE formaction property.


Definition and Usage

formaction property overrides form element's action attribute.

This attribute type = "submit" used in conjunction.


Differences between HTML 4.01 and HTML5

formaction property is new in HTML 5 attributes.


grammar

<button type="submit" formaction=" URL ">

Property Value

描述
URL 规定将表单数据发送到的地址。

可能值:

  • 绝对 URL - 完整的页面URL地址(如:href="http://www.example.com/formresult.html")
  • 相对 URL 地址 -指向当前网站的一个文件(如:href="formresult.html")


HTML button labels Reference Manual HTML <button> tag