How to combine this javascript because I have problem when selecting the grade-11 and grade-12 the work did not work but only the BSCS pick by user thank you for help
document.getElementById('course').onchange = function() {
if (["BSCS", "BSIT","BSHRM","BSBM","BSTM"].indexOf(this.value) > -1) {
document.getElementById("grade-11").setAttribute("disabled", true);
document.getElementById("grade-12").setAttribute("disabled", true);
}
else {
document.getElementById("grade-11").removeAttribute("disabled");
document.getElementById("grade-12").removeAttribute("disabled");
}
}
document.getElementById('course').onchange = function() {
if (["STEM", "TOP","GAS","HUMSS"].indexOf(this.value) > -1) {
document.getElementById("first-year").setAttribute("disabled", true);
document.getElementById("second-year").setAttribute("disabled", true);
document.getElementById("third-year").setAttribute("disabled", true);
document.getElementById("fourth-year").setAttribute("disabled", true);
} else {
document.getElementById("first-year").removeAttribute("disabled");
document.getElementById("second-year").removeAttribute("disabled");
document.getElementById("third-year").removeAttribute("disabled");
document.getElementById("fourth-year").removeAttribute("disabled");
}
}
document.getElementById('course').onchangeto be one thing then you set it to something else, overwriting the first. You could useelement.addEventListenerto add multiple event listeners, or you could combine the code in the two onchange functions into one function.