li7y/static/app.js

15 lines
605 B
JavaScript
Raw Normal View History

2024-07-05 12:38:45 +02:00
// SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
(() => {
// Allows a form checkbox to toggle an input element.
// This requires the form to have a structure like described in the bootstrap documentation:
// https://getbootstrap.com/docs/5.3/forms/input-group/#checkboxes-and-radios
Array.from(document.getElementsByClassName("input-toggle")).forEach(el => {
el.addEventListener("change", e => {
e.target.parentElement.parentElement.querySelector("input:not(.input-toggle)").disabled = !e.target.checked;
})
})
})()