problems with an optional checkbox

kraadde 05 Nov, 2025

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>

Max_admin 06 Nov, 2025

Hi Kraadde

Why not use the Triggers & Listeners behavior for this ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
kraadde 12 Nov, 2025

Max,  i have an event switscher for 2 different situations, one is providing a  dropdown for the selection of starting points = zusteige_ort.

the second situation is providing a text field for the entry of an individual starting point=zusteige_ort.

outside the event switcher, i need a checkbox for the user to select if a parking place is required, but only if the selected zusteige_ort is equal to "Ruetihof" in any of the 2 above selected situation.

How do youi propose to solve that? Trigger and Listener how to trigger depending on a selected value? 

Max_admin 12 Nov, 2025

Hi kraadde

Event Switcher is used when the value is available on page Load, like a query parameter or a database value or PHP

Triggers and Listeners are for live changes by the user on the form

Which one you are using ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Post a Reply