title: Dynamically disable select menu based on text field value
body: <p>I'd like to be able to disable a select menu on my page when a user starts typing in a text field. This is because the text field is an alternative way to enter the data and disabling the dropdown menu will help make that clearer.</p>
  
  <p>I know I could use this:</p>
  
  <pre><code>&lt;select name="specialty" id="specialty" disabled="disabled"&gt;
  </code></pre>
  
  <p>to disable the select permanently, but is there a way to assign that attribute dynamically when the value of a text field changes? I know there is no css property to do it like there is for text inputs and textareas.</p>
  
  <p>Something I found is a JQuery solution for disabling options within a select:</p>
  
  <p><a href="https://stackoverflow.com/questions/7450370/disable-select-options-based-on-value">Disable select options based on value *through the HTML only!*</a></p>
  
  <p>I tried modifying this to disable the whole select but with no success (id of text field is testinput):</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  $("#testinput").change(function(){
      $("#specialty").attr("disabled","disabled");
  }
  );
  
  &lt;/script&gt;
  </code></pre>
  
  <p>This is a simplified version (the real function should check the length of the string in testinput and decide whether to disable or enable the select based on that), but if someone can help me get this working, then modifying it is easy.</p>