How can I show/hide option in drop down list?

How can I show/hide option in drop down list?

Hi
I am trying to show and hide option in a drop down menu using jQuery.

I pass an id to a php file using getSON then i return ids list. Then I do a check for every option in a menu if this option value exists in the array show it otherwise hide it.

this is my current error 
Uncaught Error: Syntax error, unrecognized expression: #result_code_menu option[value=[object Object]]

This is my current code

  1. $(document).ready(function() {


  2. $('#call_code_menu').change( function(){
  3. $.getJSON("ajax/getResutCode.php", {
  4. id: $(this).val()
  5. },function (data) {
  6. if ( ! data) 
  7. return;
  8. var rsToUse = new Array();
  9. $.each(data ,function(i,v){
  10. rsToUse.push(v);
  11. console.log( v );
  12. });
  13. $("#result_code_menu option").each(function() {
  14. if(  $.inArray(  $(this), rsToUse)  )
  15. $("#result_code_menu option[value=" + $(this) + "]").show();
  16. else 
  17. $("#result_code_menu option[value=" + $(this) + "]").hide();
  18. });
  19. });
  20. });
  21. });


Can some one help me with this please

thanks