feat: update forms instructions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
closes: #1
This commit is contained in:
parent
5c359c4090
commit
e2a97f1059
1 changed files with 8 additions and 2 deletions
|
@ -24,7 +24,11 @@ Forms can be added to websites with just the HTML code for it. For
|
||||||
instance:
|
instance:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<form id="newsletter-form" method="POST">
|
<form
|
||||||
|
id="newsletter-form"
|
||||||
|
method="POST"
|
||||||
|
action="https://<librepages-endpoint>/?path=<current-path>&host=<current-host>"
|
||||||
|
>
|
||||||
<p>
|
<p>
|
||||||
Interested in receiving latest news about our cool product? Sign
|
Interested in receiving latest news about our cool product? Sign
|
||||||
up for you fantastic newsletter!
|
up for you fantastic newsletter!
|
||||||
|
@ -60,7 +64,8 @@ JavaScript code:
|
||||||
const form = document.getElementById("newsletter-form");
|
const form = document.getElementById("newsletter-form");
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
const url = window.location;
|
const url =
|
||||||
|
"https://<librepages-endpoint>/api/v1/forms/submit?host=<current-host>&path=<current-path>";
|
||||||
const data = {
|
const data = {
|
||||||
email: document.getElementById("email"),
|
email: document.getElementById("email"),
|
||||||
};
|
};
|
||||||
|
@ -77,4 +82,5 @@ JavaScript code:
|
||||||
form.addEventListener("submit", handleSubmit);
|
form.addEventListener("submit", handleSubmit);
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: the following snippet also demonstrates JSON form submission
|
> Note: the following snippet also demonstrates JSON form submission
|
||||||
|
|
Loading…
Reference in a new issue