for (var i = 0; i < pageSubItemForms.length; i++) {
var has_undergrad = false
var has_graduate = false
for (const [key, val] of Object.entries(mf_college_majors_list)) {
if (val["undergrad"] > 0) {
has_undergrad = true
} else if (val["graduate"] > 0) {
has_graduate = true
}
}
var college_slug = college_slug = document.URL.split("/")[4];
if ("mf_college_slug" in metaValues) {
college_slug = metaValues["mf_college_slug"]
}
//console.log("college_slug=" + college_slug);
var section = document.URL.split("/")[3];
var tempS = ""
if (has_undergrad) {
if (section =="colleges") {
tempS += "";
} else {
tempS += "";
}
}
if (has_graduate) {
if (section =="graduate-schools") {
tempS += "";
} else {
tempS += "";
}
}
if (tempS != "") {
pageSubItemForms[i].pageSubItemSelect.innerHTML = tempS;
}
var optgroup = document.createElement("optgroup");
optgroup.label = "Undergrad Program Reports";
for (const [key, val] of Object.entries(mf_college_majors_list)) {
if (val["level_code"] == "1" && val["undergrad"] > 0) {
var option = document.createElement("option");
option.value = "/colleges/" + college_slug + "/academic-life/academic-majors/" + key + "/"
option.text = " > " + val["name"]
optgroup.appendChild(option);
}
}
pageSubItemForms[i].pageSubItemSelect.appendChild(optgroup);
var optgroup = document.createElement("optgroup");
optgroup.label = "Graduate Program Reports";
for (const [key, val] of Object.entries(mf_college_majors_list)) {
if (val["level_code"] == "1" && val["graduate"] > 0) {
var option = document.createElement("option");
if (val["masters"] > 0) {
option.value = "/graduate-schools/" + college_slug + "/masters-degrees/" + key + "/"
} else {
option.value = "/graduate-schools/" + college_slug + "/doctorate-degrees/" + key + "/"
}
option.text = " > " + val["name"]
optgroup.appendChild(option);
}
}
pageSubItemForms[i].pageSubItemSelect.appendChild(optgroup);
}
// add listener to go to new sport on selection
for (var i = 0; i < pageSubItemForms.length; i++) {
pageSubItemForms[i].pageSubItemSelect.addEventListener("change", function() {
window.location.href = this.value;
});
};