Instead of having individual variables for each episode, and then iterating over all of them, use an array.
By using an array, you can use a for
loop to iterate over all of them, turning the potentially massive amount of loops into one loop:
function season3episodesChange() {
//Episodes:
var episodes = [
"1 - The Thin White Line",
"2 - Brian Does Hollywood",
"3 - Mr. Griffin Goes to Washington",
"4 - One If by Clam, Two If by Sea",
"5 - And the Wiener Is...",
"6 - Death Lives",
"7 - Lethal Weapons"
];
var selectseason3episode = document.getElementById('selectseason3episode');
for (var i = 1; i <= episodes.length; i++){
if (selectseason3episode.value == episodes[i]episodes[i - 1]){
document.getElementById('season3episode'+ i).style.display = 'inline-block';
} else {
document.getElementById(['season3episode' + i].join('')).style.display = 'none';
}
}
}