Link to home
Start Free TrialLog in
Avatar of smegghead
smeggheadFlag for United Kingdom of Great Britain and Northern Ireland

asked on

disabled in select option not working

Hi, I'm trying to create a listbox with 6 elements, the top one of which will be disabled (i.e. not clickable).

I'm including the 'disabled' parameter in the option statement, but it seems to ignore it.

It's in my HTML manual under both 'option' and 'select', it works ok under 'select', but I only want the ability to disabled individual list items.

This is my code...

<select name='fred' size=6>
 <option disabled>Title</option>
 <option value='2-1'>Free</OPTION>
 <option value='2-2'>Free</OPTION>
 <option value='2-3'>Free</OPTION>
 <option value='2-4'>Free</OPTION>
 <option value='2-5'>Free</OPTION>
</select>

But the first item in the list is not disabled, i.e. you can click on it..

Is this a disabled feature ??

I'm using IE5.
Avatar of crazyhead
crazyhead

Try "enabled='false'", or "disabled='true'". That might work.
Avatar of knightEknight
<SCRIPT language='javascript'>
  var myndx = -1;
</script>

<select name='fred' size=6 onChange='if(this.selectedIndex==0){this.selectedIndex=myndx}else{myndx=this.selectedIndex}'>
   <option value='disabled'>Title</option>
   <option value='2-1'>Free</OPTION>
   <option value='2-2'>Free</OPTION>
   <option value='2-3'>Free</OPTION>
   <option value='2-4'>Free</OPTION>
   <option value='2-5'>Free</OPTION>
</select>
ASKER CERTIFIED SOLUTION
Avatar of knightEknight
knightEknight
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW the code above works in both Netscape and IE
Avatar of smegghead

ASKER

Thank You, I'll give it a go on Monday.. looks good though.
Thank you, and sorry about the delay.. (but I didn't say which Monday though - ha ha)

Don't suppose you know how to change the 'bgcolor' of an <option> do you ??