# 404-solution/trunk/includes/js/enableDisableApplyButton.js

404 Solution, version trunk. 36 lines.

- Page: https://pluginprobe.com/plugins/404-solution/trunk/code/includes/js/enableDisableApplyButton.js
- Raw: https://pluginprobe.com/plugins/404-solution/trunk/raw/includes/js/enableDisableApplyButton.js
- Modified: 2025-12-06T10:05:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/404-solution/trunk/code/includes/js/enableDisableApplyButton.js#L10-L20`.

```javascript

/* Here we disable the "Apply" button if there are no checkboxes selected.
    We enable it if there is at least one selected. */
function enableDisableApplyButton() {
    var shouldBeEnabled = false;
    var inputs = document.getElementsByTagName("input");
    for(var i = 0; i < inputs.length; i++) {
        if(inputs[i].type === "checkbox") {
            if (inputs[i].checked === true) {
                shouldBeEnabled = true;
                break;
            }
        }  
    }

    var button = document.getElementById("captured_404s_bulk_apply");
    var selector = document.getElementById("bulkCaptured404select");
    
    // This can be null because we're on the trash page.
    if (button === null) {
        return;
    }
    
    button.disabled = !shouldBeEnabled;
    selector.disabled = !shouldBeEnabled;
    if (shouldBeEnabled) {
        button.setAttribute("title", '');
        button.removeAttribute("aria-describedby");
        selector.setAttribute("title", '');
    } else {
        button.setAttribute("title", "{altText}");
        selector.setAttribute("title", "{altText}");
    }
}
enableDisableApplyButton();

```
