-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
22 lines (20 loc) · 886 Bytes
/
Copy pathscript.js
File metadata and controls
22 lines (20 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const scriptURL = "https://script.google.com/macros/s/AKfycbz7hCENPepXRacdk9AxYIB5kXULTObJ-LtH0qzMVlD8d_UuH6nir60V9g3XTiDfD0j5/exec";
const form = document.forms["submit-to-google-sheet"];
const btnKirim = document.querySelector(".btn-kirim");
const btnLoading = document.querySelector(".btn-loading");
const myAlert = document.querySelector(".my-alert");
form.addEventListener("submit", (e) => {
e.preventDefault();
// tombol submit di klik
btnLoading.classList.toggle("d-none");
btnKirim.classList.toggle("d-none");
fetch(scriptURL, { method: "POST", body: new FormData(form) })
.then((response) => {
btnLoading.classList.toggle("d-none");
btnKirim.classList.toggle("d-none");
console.log("Success!", response);
myAlert.classList.toggle("d-none");
form.reset();
})
.catch((error) => console.error("Error!", error.message));
});