22

i see there is a disabled property on a specific item in the dropdown list but is there an enabled property on the whole html dropdown itself?

any suggestions?

leora
  • 188,729
  • 360
  • 878
  • 1,366

3 Answers3

34

According to the HTML 4 spec a select element has a disabled attribute.

So

<select disabled>
  <option>Something</option>
</select>

should work

Joey
  • 344,408
  • 85
  • 689
  • 683
15
disabled="disabled"

This will disable a value within the combo box (it will still show up, but it will not have the ability to be selected):

<select>
  <option disabled="disabled" value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>

This will disable the whole combo box:

<select disabled="disabled">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
</select>
DaveShaw
  • 52,123
  • 16
  • 112
  • 141
Travis Heeter
  • 13,002
  • 13
  • 87
  • 129
3

may this will help

is same as :

<html>
    <head>
       <script type="text/javascript">
          function makeDisable(){
          var x=document.getElementById("mySelect")
          x.disabled=true
          }
         function makeEnable(){
             var x=document.getElementById("mySelect")
              x.disabled=false
         }</script></head><body><form>
        <select id="mySelect"><option>Apple</option><option>Banana</option>
        <option>Orange</option>
        </select>
        <input type="button" onclick="makeDisable()" value="Disable list">
        <input type="button" onclick="makeEnable()" value="Enable list">
        </form>
        </body>
       </html>
Posto
  • 7,362
  • 7
  • 44
  • 61