-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (37 loc) · 1.42 KB
/
script.js
File metadata and controls
41 lines (37 loc) · 1.42 KB
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
// Tab functionality
var tablinks = document.getElementsByClassName("tab-links");
var tabcontents = document.getElementsByClassName("tab-contents");
function opentab(tabname) {
for (let tablink of tablinks) {
tablink.classList.remove("active-link");
}
for (let tabcontent of tabcontents) {
tabcontent.classList.remove("active-tab");
}
event.currentTarget.classList.add("active-link");
document.getElementById(tabname).classList.add("active-tab");
}
for (let tablink of tablinks) {
tablink.addEventListener("click", function () {
// Use the text content of the clicked tab or a custom attribute for tabname
const tabname = this.getAttribute("data-tab");
console.log(tabname);
opentab(tabname);
});
}
// Form submission handling
const scriptURL = 'https://script.google.com/macros/s/AKfycbzTcRRJrpPbN--bnHQGK9jUgk7xIvkNLHS0FgfjIXOvBv6mDvO5gSDeKR133K3QZo909A/exec';
const form = document.forms['submit-to-google-sheet'];
const msg = document.getElementById("msg");
form.addEventListener('submit', (e) => {
e.preventDefault();
fetch(scriptURL, { method: 'POST', body: new FormData(form) })
.then(response => {
msg.innerHTML = "Message sent successfully";
setTimeout(() => {
msg.innerHTML = "";
}, 5000);
form.reset();
})
.catch(error => console.error('Error!', error.message));
});