tags:

views:

42

answers:

0

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? (Note: I'm using prototype framework library) 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');
        }

    });
}