title: jQuery enable/disable show/hide button w/ SELECT options. Get remaining option values
body: <p>I have a select list which is being populated using the values from a text field. I also have two buttons: an add button which adds the entered value to the select list and a remove button which removes the entered value from the select list. I would like to do the following using jQuery:</p>
  
  <ol>
  <li>If the value entered into the text field is <strong>NOT AVAILABLE</strong> in the select list, show the add button and hide the remove button.</li>
  <li>If the value entered into the text field is <strong>AVAILABLE</strong> in the select list, hide the add button and show the remove button.</li>
  <li>If the select list is <strong>EMPTY</strong> show the add button and hide the remove button.</li>
  </ol>
  
  <p>Here is some code I've come up with:</p>
  
  <pre><code>// Remove selected options
  $('#removeButton').click(function() {
     //$.map($('#addedchargeamtid :selected'), function(e) {
     $.map($('#addedchargeamtid option'), function(e) {
        var exp = $(e).text();
        // Would like to have all the Option values in CVS format 0.00,1.99, etc...
        // If removed this should also remove the value in the array
     })
  
     $('#removeButton').hide();
        return !$('#addedchargeamtid :selected').remove();
     });
  
     // Add charge amount
     $('#addedchargeamtid option:selected').focus(function() {
        $('#removeButton').show();
     });
  </code></pre>
  
  <p>It shows the remove button when I add the first value, but if I remove the value the button doesn't show back up.</p>
  
  <p>UPDATE:</p>
  
  <p>Okay I have edited it to this.</p>
  
  <pre><code>$('#removeButton').click(function() {
     $('#addedchargeamtid :selected').remove();
  
     $.map($('#addedchargeamtid option'), function(e) {
        var exp = $(e).text();
        alert(exp); // Need this in CSV format but I think it displays the correct values
     })
  
     //if($("#addedchargeamtid option").length &gt; 0) {  &lt;-- Didn't work                
     if($("#addedchargeamtid").length &gt; 0) {
        $('#removeButton').show();
     } else {
        $('#removeButton').hide();
     }
  });
  </code></pre>
  
  <p>still not hiding the button when no value in the SELECT. Tried it with the option as well.</p>