HTML DOM disabled Property
Complete Option Object Reference
Definition and Usage
The disabled property sets or returns whether or not an option in a dropdown
list should be disabled by default.
Note: The disabled attribute does not work properly in IE.
Syntax
optionObject.disabled=true|false
|
Example
The following example alerts if the chosen fruit is disabled by default:
<html>
<head>
<script type="text/javascript">
function alertDefaultDisabled()
{
var x=document.getElementById("mySelect").selectedIndex;
var y=document.getElementsByTagName("option");
alert("Is " + y[x].text + " disabled by default? " + y[x].disabled);
}
</script>
</head>
<body>
<form>
Select your favorite fruit:
<select id="mySelect">
<option>Apple</option>
<option>Orange</option>
<option disabled="disabled">Pineapple</option>
<option>Banana</option>
</select>
<br />
<br />
<input type="button" onclick="alertDefaultDisabled()"
value="Is the chosen fruit disabled by default?">
</form>
</body>
</html>
|
Try-It-Yourself Demos
Check if an option is disabled by default
Disable an option by id
Complete Option Object Reference
Want To Be A Web Master?
If you want to be a Web Master, you will have to host your web site with an ISP (Internet Service Provider).
MaximumASP offers seven different configurations of dedicated servers to meet your Windows and .NET hosting needs.
Hosted on our multi-tiered Enterprise Class network, these servers provide the performance, security and reliability
you need to host your high end web sites and applications.
Visit MaximumASP
|