Max I have a dropbox and want a checkbox to be visibel depending on the data choosen live in the dropbox. I experimented with a script placed inside an html field between the dropbox and the checkbox like that:, but without success, the checkbox is always visibel. Where is the mistake?
<script>
document.addEventListener('DOMContentLoaded', function () {
const dropdown = document.querySelector('[name="zusteige_ort"]'); // ← dein Dropdownname
const checkbox = document.querySelector('[name="park_platz_tw"]');
function toggleCheckbox() {
checkbox.closest('.form-group').style.display = (dropdown.value === "Ruetihof") ? 'block' : 'none';
}
dropdown.addEventListener('change', toggleCheckbox);
toggleCheckbox(); // Initialzustand
});
</script>
Hi Kraadde
Why not use the Triggers & Listeners behavior for this ?
You need to login to be able to post a reply.
