-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact_form.html
40 lines (39 loc) · 1.25 KB
/
contact_form.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!doctype html>
<html>
<head>
</head>
<body>
<h1>Contact</h1>
<div>
<form id='contactForm'>
<p>
<div><label for='comment'>Comment</label></div>
<textarea id='comment' name='comment' rows='4' cols='50' placeholder='Leave a comment'></textarea>
</p>
<p>
<div><label for='fullname'>Name</label></div>
<input id='fullname' name='fullname' placeholder='Enter name'>
</p>
<p>
<div><label for='email'>Email</label></div>
<input id='email' name='email' placeholder='Enter email address'>
</p>
<input type='submit' value='Submit'>
</form>
<div id='contactDone' style='display: none;'>Thank you for sending!</div>
</div>
</body>
<script src='https://smtpjs.com/v3/smtp.js'></script>
<script>
contactForm.onsubmit = async (e) => {
e.preventDefault();
contactForm.style.display = 'none';
contactDone.style.display = '';
let url = 'http://localhost:8000/contact';
url += '?comment=' + encodeURIComponent(comment.value);
url += '&name=' + encodeURIComponent(fullname.value);
url += '&email=' + encodeURIComponent(email.value);
fetch(url, {method: 'POST'});
}
</script>
</html>