-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (33 loc) · 1.24 KB
/
script.js
File metadata and controls
36 lines (33 loc) · 1.24 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
const scriptURL = 'https://script.google.com/macros/s/AKfycbwUuVDcYK16sejHZiYoYZa2DncKKpDzPHT0EpqUL-_c0-_SLl4jKkyqFW3uw_9W9zClHQ/exec'
const form = document.forms['submit-to-google-sheet']
const mg = document.getElementById('send')
form.addEventListener('submit', e => {
e.preventDefault()
fetch(scriptURL, { method: 'POST', body: new FormData(form)})
.then(response => {
mg.innerHTML = "Message sent successfully"
setTimeout(function(){
mg.innerHTML = ""
},3000)
form.reset()
})
})
.catch(error => console.error('Error!', error.message))
/* Dropdown for smaller width */
// When the user clicks on the button, toggle between hiding and showing the dropdown content
function myDropdown() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}