Disabling options in option list only works in IE

F

Fluffy Convict

I have found a workaround to disable certain options in an option list:

var p = document.forms[0].elements['myOptionList'];
p.selectedIndex=-1;

This works perfectly in IE - the selectedIndex becomes unclickable. It
does, however, not work in FireFox. Does any body have clue why not?

Any help would be greatly appreciated :)
 
R

RobG

Fluffy said:
I have found a workaround to disable certain options in an option list:

var p = document.forms[0].elements['myOptionList'];
p.selectedIndex=-1;

This works perfectly in IE - the selectedIndex becomes unclickable.

Not for me.
does, however, not work in FireFox. Does any body have clue why not?

It does not disable anything. It just moves the selected option to the
one before 0, both Firefix and IE display a blank option (a reasonable
outcome I reckon) but all options are still selectable, nothing has
been disabled.

Play code follows:

<html>
<head>
<title>Option play</title>
<script type="text/javascript">
function tryIt() {
var p = document.forms[0].elements['myOptionList'];
p.selectedIndex=-1;
}
</script></head><body>
<form action="">
<select name="myOptionList">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
<input type="button" value="Click me" onclick="tryIt();">
</form>
</body>
</html>
 
M

Michael Winter

My apologies if this double (triple?) -posted. googlegroups2 beta is the
worst.

The thing I'm most annoyed about is that old links to the archived
messages no longer work. Anyway, if you have a proper news reader
(preferably not OE :p), you could always apply for an account at
<URL:http://www.individual.net/>. It's free.

[snip]

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top