i-eat.rocks/site/apps/guestbook/tracker.js
2024-09-13 20:49:46 -06:00

33 lines
No EOL
1,012 B
JavaScript

const nameLabel = document.getElementById("namelabel");
const nameBox = document.getElementById("name");
nameBox.addEventListener("input", function() {
nameLabel.innerText = `Name (${64 - nameBox.value.length} characters left):`;
})
const msgLabel = document.getElementById("msglabel");
const msgBox = document.getElementById("message");
msgBox.addEventListener("input", function() {
msgLabel.innerText = `Message (${600 - msgBox.value.length} characters left):`;
})
document.getElementById("submitForm").reset();
document.getElementById("submitForm").addEventListener("submit", function(event) {
event.preventDefault();
const formData = new FormData(event.target);
document.getElementById("submitButton").disabled = true;
fetch(macroURL, {
method:"POST",
body: new URLSearchParams(formData)
})
.then(response => response.json())
.then(data => {
event.target.reset();
window.location.reload()
});
});