Skip to content Skip to sidebar Skip to footer

Merge Two Javascript Scripts

I have two JavaScript code snippets. These perform specific task when an 'Update' button is clicked. I would like to merge them. Any help is appreciated. JavaScript 1: When the but

Solution 1:

I'm really not sure what you want to do, but here's a stab at it:

functiondoUpdate(){
    var c = document.getElementsByTagName('input');
    for (var i = 0; i < c.length; i++) {
        if (c[i].type == 'checkbox' && c[i].checked == true) {
            // At least one checkbox is checked    UpdateHoliday();
            returntrue;
        }
    }
    // Nothing has been checkedalert("Please identify what warehouses comply:");
    returnfalse;
}

functionUpdateHoliday(){
    checked = false;
    functionAll (holiDay) {
        var all = document.getElementById('holiDay');
        checked = !checked;
        for (var i =0; i < all.elements.length; i++){
            all.elements[i].checked = checked;
        }
    }
    //after checked or unchecked all checkboxes then submit the form and other functionalitydocument.holiDay.command.value = 'update';
    document.holiDay.submit();  
} 

It would really help to simplify and indent your code so that we could understand it more clearly.

Post a Comment for "Merge Two Javascript Scripts"