// The first course is course to take, followed
// by an array of pre-requisites
// courses is an array of arrays
// each element of courses contains
// a string - the course in question
// an array - an array of the pre-requisites of the course
// Note that the Checkbox id in the html is also
// the first element of each array element of courses
var courses = [
['MAC1140', ['MAC1105']],
['MAC1114', ['MAC1105']],
['MAC2311', ['MAC1140','MAC1114']],
['PHY2048', ['MAC2311']],
['EGN3046', ['MAC2311']],
['EET3085', ['MAC1114']],
['ETS3543', ['MAC1105']],
['ETI3116', ['STA2023']],
['ETI3421', ['MAC1114']],
['EGN3311', ['MAC2311', 'PHY2048']],
['EGN3321', ['EGN3311']],
['ETM4220', ['MAC2311']],
['EGN3613', ['MAC2311']],
['ETS4502', ['EGN3311']],
['ETI4448', ['MAC2311', 'EGN3613']],
['ETG4950', ['ETI4448']]
]
function pr(item, index) {
// item[0] is the course in question (string)
var checked = true;
// item[1] is the array of pre-requisites (array of strings)
var elementId = item[1][0];
// Goes through the list of pre-requisites
// to see if each one is met if any are not met
// then pre-requisites are not met
for (var i=0; i<item[1].length; i++){
elementId = item[1][i];
if (!isChecked(elementId)) {
checked=false;
}
}
// and if all are met - enables taking courses
// checked is true/false Enable is a function call to Enable
// item[0] is the first element of the array item - which is the
// course in question
// item[0] - courses
// item[1] - array of pre-requisite courses
if (checked) {Enable(item[0])
}
else{ Disable(item[0])}
}
function CC()
{
courses.forEach(pr);
}
function isChecked(item) {
return (document.getElementById(item).checked == true);
}
// The function Enable sets the disabled property of the interface element
// to false. In effect making it enabled.
function Enable(selection){
document.getElementById(selection).disabled =...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.