-
Notifications
You must be signed in to change notification settings - Fork 0
/
form.html
63 lines (54 loc) · 2.14 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="images/icon.ico">
<link rel="stylesheet" href="styles.css">
<!-- Google fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Major+Mono+Display&display=swap" rel="stylesheet">
<title>submit</title>
</head>
<body class="nonscreen" style="margin-top: 20%;">
<form id="newPhrase" class="" action="#" method="post">
<label for="screen1">screen 1:</label>
<input type="text" id="screen1" name="screen1" maxlength="20"><br>
<label for="screen2">screen 2:</label>
<input type="text" id="screen2" name="screen2" maxlength="20"><br>
<label for="screen3">screen 3:</label>
<input type="text" id="screen3" name="screen3" maxlength="20"><br>
<label for="screen4">screen 4:</label>
<input type="text" id="screen4" name="screen4" maxlength="20"><br>
<label for="screen5">screen 5:</label>
<input type="text" id="screen5" name="screen5" maxlength="20"><br>
<input type="submit" id="submit" value="submit">
</form>
<div><a href="index.html"><h4>< home</h4></a></div>
</body>
<script type="text/javascript">
const form = document.getElementById("newPhrase");
const submitButton = document.getElementById("submit");
const scriptURL = 'https://script.google.com/macros/s/AKfycbyV2_GT70vsSt9ndkCDTmHsOsTNEiAWSBsakfKrGoNCUusl6wNCvRuPVWBGHmyddDSSWw/exec';
form.addEventListener("submit",
e => {
submitButton.disabled = true;
e.preventDefault();
let requestBody = new FormData(form);
fetch(scriptURL, {
method: 'POST',
body: requestBody
})
.then(response => {
alert('Submission successful', response)
submitButton.disabled = false
})
.catch(error => {
alert('Error - try again or contact atorre03@risd.edu', error.message)
submitButton.disabled = false
});
form.reset();
}
)
</script>
</html>