-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Submit A Form With A Button Outside The Form | ||
|
||
You can tie a submit button to a form that the button doesn't live inside of. The trick is to give the form an `id` and then reference that `id` with the button's `form` property. | ||
|
||
```html | ||
<div> | ||
<form id="my-form"> | ||
<label for="name">Name:</label> | ||
<input type="text" name="name"></input> | ||
</form> | ||
|
||
<!-- ... --> | ||
|
||
<button type="submit" form="my-form">Submit</button> | ||
</div> | ||
``` | ||
|
||
With this setup, clicking the _Submit_ button will cause the form to be submitted. | ||
|
||
See the [MDN Button docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) for more details. | ||
|