Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

HTML formaction 属性


定义和用法

当提交表单时,formaction 属性指定将表单数据发送到哪里。此属性会覆盖表单的 action 属性。

formaction 属性仅用于 type="submit" 的输入/按钮。


适用于

formaction 属性可以在以下元素上使用

元素 属性
<button> formaction
<input> formaction

示例

按钮示例

一个带有两个提交按钮的表单。第一个提交按钮将表单数据提交到“action_page.php”,而第二个提交到“action_page2.php”

<form action="/action_page.php" method="get">
  姓氏:<input type="text" name="fname"><br>
  名字:<input type="text" name="lname"><br>
  <button type="submit">提交</button><br>
  <button type="submit" formaction="/action_page2.php">提交到另一个页面</button>
</form>
自己试试 »

输入示例

一个带有两个提交按钮的 HTML 表单,具有不同的操作

<form action="/action_page.php">
  姓氏:<input type="text" name="fname"><br>
  名字:<input type="text" name="lname"><br>
  <input type="submit" value="提交"><br>
  <input type="submit" formaction="/action_page2.php" value="提交到另一个页面">
</form>
自己试试 »

浏览器支持

formaction 属性对每个元素的浏览器支持如下

元素
button 9.0 10.0 4.0 5.1 10.6
input 9.0 10.0 4.0 5.1 10.6

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.