I am a new and junior developer here. I have one problem with IE8, my code works fine in Firefox, but it doesn't work in IE at all.
I have 2 select multiple in my code, and I want to show several second choice options for selection in the first.
HTML:
<form name="formMenu">
<table>
<tr>
<td align="center">
<select multiple name="selectOne" title="selectOne" class="selectOne"
style="width:180px;height:60px">
<option value="abc" onclick="Javascript:obtainSecondChoices()">
abc
</option>
<option value="def" onclick="Javascript:obtainSecondChoices()">
def
</option>
</select>
</td>
</tr>
<tr>
<td align="center">
<select multiple name="selectTwo" title="selectTwo" class="selectTwo"
style="width:180px;height:60px">
<option class="abc" value="selTwoOpt1" style="display:none;">
selTwoOpt1
</option>
<option class="def" value="selTwoOpt2" style="display:none;">
selTwoOpt2
</option>
<option class="abc" value="selTwoOpt3" style="display:none;">
selTwoOpt3
</option>
</select>
</td>
</tr>
</table>
</form>
Javasript:
function obtainSecondChoices(){
var fstSelects = document.formMenu.selectOne;
for(var i = 0 ; i < fstSelects.length; i++){
var fstSelect = fstSelects[i];
if(fstSelect.selected){
var scndSelects = document.formMenu.selectTwo;
for(var j = 0; j< scndSelects.length; j++){
if(scndSelects[j].className == fstSelect.value){
scndSelects[j].style.display = '';
}
}
} else {
var scndSelects = document.formMenu.selectTwo;
for(var j = 0; j< scndSelects.length; j++){
if(scndSelects[j].className == fstSelect.value){
scndSelects[j].style.display = 'none';
scndSelects[j].selected = false;
}
}
}
}
}
This should show or hide and deselect the second option, depending on what you selected in the first options.
As I said, it works fine in Firefox, but Internet Explorer is not even initially hidden with the display: none;
Thanks in advance and sorry for my poor english.
source
share