First you must remove onclick="option_hide(1)"
options in your elements. Onclick
in the option tag doesn't work in other browsers. Onclick
Use onchange
in tag instead select
.
eg.
<select name="team_compare1" id="team_compare1" onchange="option_hide(1)">
The problem is that you are hiding the parameter in the selected combobox because you are targeting the item based on the list you selected instead of the opposite.
This:
if (list == 1) {
option_to_hide2 = document.getElementById(team_selected + list);
option_to_hide2.style.display = 'none';
}
You should change this to:
if (list == 1) {
option_to_hide2 = document.getElementById(team_selected + 2);
option_to_hide2.style.display = 'none';
}
Fiddle
source
to share