This code works(i know this is the wrong way to use switch), BUT it seems like I'm approaching this problem the wrong way. I have two dropdownmenu boxes on my webpage with values that can be mix anyhow.
e.g with 2 values in each box:
- 1|1
- 1|2
- 2|1
- 2|2
But it will be with perhaps 20 values, so it the code will grow quite fast. I have to know what the user have chosen in both boxes and the mix of them, cause it will present data regarding both boxes and the mix of them.
So in short my question is; is there any optimal solution of doing this? I want the page to load fast and be easy to maintain.
function solveit() {
//These are dropdownlist that will just send and index or value as text
var selectedIndex1 = document.getElementById("selectedIndex1").value;
var selectedIndex2 = document.getElementById("selectedIndex2").value;
switch (selectedIndex1 + "|" + selectedIndex2){
case "1|1":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "1|2":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "1|3":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "1|4":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "1|5":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "2|1":
document.getElementById("IndexANDIndex").innerHTML = "Info about the two values"
break;
case "2|2":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "2|3":
document.getElementById("IndexANDIndex").innerHTML = "Info about the two values"
break;
case "2|4":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "2|5":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "3|1":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "3|2":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "3|3":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "3|4":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "3|5":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
//And so on...
case "1|1":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "2|1":
document.getElementById("IndexANDIndex").innerHTML = "Info about the two values"
break;
case "3|1":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "4|1":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
case "5|1":
document.getElementById("IndexANDIndex").innerHTML = "Information about the combination of them"
break;
//And so on...
default:
document.getElementById("IndexANDIndex").innerHTML = "NOTHING CHOOSEN"}
}