Skip to content

Commit 6b139d8

Browse files
authored
Create index file [PF]
1 parent a422eb4 commit 6b139d8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

index.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<form id="contact-form">
2+
<input type="text" name="name" placeholder="Your Name" required /><br />
3+
<input type="email" name="email" placeholder="Your Email" required /><br />
4+
<textarea name="message" placeholder="Your Message" required></textarea><br />
5+
<button type="submit">Send</button>
6+
</form>
7+
8+
<script>
9+
const form = document.getElementById("contact-form");
10+
form.addEventListener("submit", async (e) => {
11+
e.preventDefault();
12+
const formData = new FormData(form);
13+
const data = Object.fromEntries(formData.entries());
14+
15+
const response = await fetch("YOUR_WEB_APP_URL", {
16+
method: "POST",
17+
body: JSON.stringify(data),
18+
headers: {
19+
"Content-Type": "application/json",
20+
},
21+
});
22+
23+
if (response.ok) {
24+
alert("Message sent successfully!");
25+
form.reset();
26+
} else {
27+
alert("There was a problem sending your message.");
28+
}
29+
});
30+
</script>

0 commit comments

Comments
 (0)