<script>
document.addEventListener('DOMContentLoaded', function() {
const checkboxes = document.querySelectorAll('.w-checkbox-input');
const textArea = document.getElementById('reason-value');
checkboxes.forEach(checkbox => {
checkbox.addEventListener('change', updateTextInput);
});
function updateTextInput() {
const selectedLabels = Array.from(checkboxes)
.filter(checkbox => checkbox.checked)
.map(checkbox => {
// Find the associated label text
return checkbox.parentElement.querySelector('.w-form-label').textContent.trim();
});
textArea.value = selectedLabels.join(', ');
}
});
</script>