smegghead
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.
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.
Try "enabled='false'", or "disabled='true'". That might work.
<SCRIPT language='javascript'>
var myndx = -1;
</script>
<select name='fred' size=6 onChange='if(this.selected Index==0){ this.selec tedIndex=m yndx}else{ myndx=this .selectedI ndex}'>
<option value='disabled'>Title</op tion>
<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>
var myndx = -1;
</script>
<select name='fred' size=6 onChange='if(this.selected
<option value='disabled'>Title</op
<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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW the code above works in both Netscape and IE
ASKER
Thank You, I'll give it a go on Monday.. looks good though.
ASKER
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 ??
Don't suppose you know how to change the 'bgcolor' of an <option> do you ??