> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/net/html-form-submit-to-different-action-depending-on-properties.md).

# html form submit to different action depending on properties

Sometimes you want the form to submit to different URL based on which submit button you click. This is already supported by HTML with `formaction` attribute

example

```
 <form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>

  <button type="submit">Submit</button>
  <button type="submit" formaction="/action_page2.php">Submit to another page</button>
</form> 
```

More information on the attirbute <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-formaction>
