Javascript: Remove checked status from disabled input on load (already checked)

Posted by BoDiE2003 on Stack Overflow See other posts from Stack Overflow or by BoDiE2003
Published on 2010-05-17T13:45:59Z Indexed on 2010/05/17 13:50 UTC
Read the original article Hit count: 172

Filed under:

On load, the script is not un-checking the disabled checkboxes, I have tried everything. I have even tried running this code from Chrome Console, and it is working, but not in normal ways. Where is the error?Javascript:

document.observe("dom:loaded", function() {
    $(document.body).select('input').each(function(element) {
        init();
        element.observe('click', function(element) {
            init();
        });
    });
    loopGroup1();
    loopGroup3();
    loopGroup4();
});

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

    });
}

© Stack Overflow or respective owner

Related posts about JavaScript