ttomaszewicz
asked on
<select> <option> does not accept style.display='none' under IE. Any Workaround?
Following demo code works fine for Firefox. IE6 ignores the update of style.display property.
Would you please help me?
the example code should allow the last option be selected only for the first attempt. Next time the option should be disabled.
n.b. also
document.getElementById("t est").opti ons[2].dis abled=true
does not work in IE, while is OK with Firefox.
Would you please help me?
the example code should allow the last option be selected only for the first attempt. Next time the option should be disabled.
n.b. also
document.getElementById("t
does not work in IE, while is OK with Firefox.
<H2>demo</h2>
<form>
<select id='test' name='test' onChange='document.getElementById("test").options[2].style.display="none"' >
<option id='test1' value='test1'>---test1---</option>
<option id='test2' value='test2'>---test2---</option>
<option id='test3' value='test3'>---test3---</option>
</select>
other inputs
</form>
i added one line checking. update the script to
<script type="text/javascript">
var flag = false;
function disableOption2(obj){
if(flag){
if(obj.options.length==3){
obj.options[2] = null;
}
}
flag = true;
}
</script>
ASKER
This works! Thanks!
Is there a way to revert the last option - to be visible and selectable again? e.g. after pressing a button?
Is there a way to revert the last option - to be visible and selectable again? e.g. after pressing a button?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is what I needed. Thank you for your help.
Open in new window