title: jquery - triggering change event on select control - can't determine value afterwards
body: <p>I have the following jquery code: </p>
  
  <pre><code>$("#ruletypes").change(function()  {                        
      var selectedtype = this.value;                  
      var url;
      if (selectedtype == 1) {
          url = url1;
      } else {
          url = url2;
      }                       
      $.getJSON(
          url,
          function(data) {
              data = $.parseJSON(data); //converting to a javascript object vs. just string....                                  
              if (data !=null){
                  //remove everything in current list.
                  $('#contact_types')
                  .find('option')
                  .remove() 
                  .end()                      
                  //loop through results and add each one     
                  $.each(data, function(i) {
                      $('#contact_types')
                      .append($("&lt;option&gt;&lt;/option&gt;")
                      .attr("value",this.id)                                                  
                      .text(this.description));
                  }); //end .each                             
              }//end if
          }//end function(data)
      );//end getJSON.    
  
      //set default values for contact type
      if (selectedtype == 1)  {                   
          $('#contact_types').val(2).change();  
      } else  {
          $('#contact_types').val(1).change(); 
      }
  });//end ruletypes.change
  
  $("#contact_types").change(function () {
      var selectedtext = $("#contact_types option:selected").html();
      alert("select value of contact type is" + selectedtext);
      alert(this.value);
  });
  </code></pre>
  
  <p>My problem / question is that once I programmtically trigger the change event for the contact_types select box, I can't seem to be able to determine what the value is..
  The two alert statements that I have  return undefined and null respectively. </p>
  
  <p>I've also tried .text().</p>
  
  <p>Can you tell me where my bug is?  I need to be able to determne the value of the currently selected item in contact_types.</p>
  
  <p>Thanks. </p>