I have two pieces of JavaScript code. They perform a specific task when you click the Refresh button.
I would like to combine them. Any help is appreciated.
JavaScript 1: When a button is clicked, it checks to see if at least one checkbox is selected:
function doUpdate(){ 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 document.holiDay.command.value= 'update'; document.holiDay.submit(); return true; } } // Nothing has been checked alert("Please identify what warehouses comply:"); return false; }
JavaScript 2: when a check box is selected and the refresh button is clicked, check all or clear the check box if all the boxes are unchecked; then execute the update function:
function doUpdate(){ checked=false; function All (holiDay) { var all= document.getElementById('holiDay'); if (checked == false){ checked = true } else{ checked = false } for (var i =0; i < all.elements.length; i++){ all.elements[i].checked = checked; } }
source share