There is a nicer/simpler solution than this?
thanks, regards
======================
document.addEventListener('click', function (event) {
// Get the element that was clicked
const clickedElement = event.target;
// Check if the clicked element's ID is 'GridDistinteChild___Ricambio' and is a checkbox
if (clickedElement.id === 'GridDistinteChild___Ricambio' && clickedElement.type === 'checkbox') {
const checkboxValue = clickedElement.checked; // true if checked, false if not checked
console.log(`Checkbox is ${checkboxValue ? 'checked' : 'unchecked'}`);
// Array of IDs to toggle the class
const relatedInputs = [
'GridDistinteRicambioLivCriticita',
'GridDistinteRicambioConsumabile',
'GridDistinteRicambioQtaConsigliata'
];
// Loop through each related input and toggle classes
relatedInputs.forEach(id => {
const parentElement = document.querySelector(`#${id}`).parentNode;
parentElement.classList.toggle('e-disabled', !checkboxValue);
parentElement.classList.toggle('e-enabled', checkboxValue);
});
}
});