views:

105

answers:

1

Im trying to make this function to check an element and if its checked, or not, add or remove respective className. Also, if the element is disabled but is checked, it should un-check it and remove the className('yes')

function init() {
    $(document.body).select('input').each(function(element) {
        if (!element.checked) {
            element.up().removeClassName('yes');
        } else {
            element.up().addClassName('yes');
        }
        if (element.checked && element.disabled) {
            element.checked = false;
            element.up().removeClassName('yes')
        }
    });

}

Right now, the last part, is not working, no effect

A: 

Did you try element.checked = !element.checked in the last part instead of element.checked = false?

Robusto
This works, but I have problems to make it work from the document load:Im using this source to make it work:
BoDiE2003