@ -674,7 +674,7 @@ input.invalid, select.invalid, textarea.invalid {
< div class = "actions" >
< div class = "actions" >
< button type = "button" class = "btn btn-primary" onclick = "exportCSV()" > 📥 Exporteer CSV< / button >
< button type = "button" class = "btn btn-primary" onclick = "exportCSV()" > 📥 Exporteer CSV< / button >
< button type = "button" class = "btn btn-success" onclick = "sendEmail( )"> 📧 Verstuur per Email< / button >
< button type = "button" class = "btn btn-success" onclick = "sendEmail( this )"> 📧 Verstuur per Email< / button >
< button type = "button" class = "btn btn-danger" onclick = "clearForm()" > 🗑️ Formulier Wissen< / button >
< button type = "button" class = "btn btn-danger" onclick = "clearForm()" > 🗑️ Formulier Wissen< / button >
< / div >
< / div >
@ -1042,12 +1042,22 @@ input.invalid, select.invalid, textarea.invalid {
};
};
// Send email
// Send email
window.sendEmail = function() {
window.sendEmail = function(btn ) {
if (!validateAll()) {
if (!validateAll()) {
showToast('Vul eerst alle verplichte velden in', 'error');
showToast('Vul eerst alle verplichte velden in', 'error');
return;
return;
}
}
// Show loading state immediately
const button = btn || document.querySelector('[onclick*="sendEmail"]');
const originalText = button ? button.innerHTML : '';
if (button) {
button.innerHTML = '⏳ Email voorbereiden...';
button.disabled = true;
}
// Use setTimeout to allow UI to update before heavy processing
setTimeout(function() {
const data = getFormData();
const data = getFormData();
// Build subject
// Build subject
@ -1085,7 +1095,14 @@ input.invalid, select.invalid, textarea.invalid {
'?subject=' + encodeURIComponent(subject) +
'?subject=' + encodeURIComponent(subject) +
'& body=' + encodeURIComponent(body);
'& body=' + encodeURIComponent(body);
// Restore button state
if (button) {
button.innerHTML = originalText;
button.disabled = false;
}
window.location.href = mailto;
window.location.href = mailto;
}, 50);
};
};
// Clear form
// Clear form