mirror of
https://github.com/Matewoo/tablet-web-survey.git
synced 2026-11-18 13:52:47 +01:00
add timeout to submit button
When pressing the submit button you must wait 1 second to press again.
This commit is contained in:
+11
-3
@@ -8,15 +8,16 @@ document.querySelectorAll('.emoji').forEach(button => {
|
||||
}
|
||||
button.classList.add('selected');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('submit').addEventListener('click', () => {
|
||||
document.getElementById('submit').addEventListener('click', () => {
|
||||
const results = {};
|
||||
document.querySelectorAll('.emoji.selected').forEach(button => {
|
||||
const category = button.getAttribute('data-category');
|
||||
results[category] = button.id;
|
||||
});
|
||||
|
||||
if (Object.keys(results).length > 0) {
|
||||
fetch('/submit', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -36,4 +37,11 @@ document.querySelectorAll('.emoji').forEach(button => {
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const submitButton = document.getElementById('submit');
|
||||
submitButton.disabled = true;
|
||||
setTimeout(() => {
|
||||
submitButton.disabled = false;
|
||||
}, 1000);
|
||||
});
|
||||
Reference in New Issue
Block a user