title: alert show 4 times in this code
body: <p>I have this code:</p>
  
  <pre><code>    &lt;script  language="javascript"&gt;
    $(function() {
      $('#items,#button-search').hide();
      $("#companies").click(function() { 
        $(this).attr("value",""); 
        $('#address,#new-company-form').empty();
      });
      $( "#companies" ).autocomplete({
        source: ";companies",
        minLength: 2,
        select: function( event, ui ) {
          $('#address').show();
          if(ui.item.id == "create-new-company") {
            // call the new company form
            $('#address').empty();
            //$('#new-company-form').load('/companies/;new_resource?type=company #autoform',
            $('#new-company-form').load(';company_form #autoform');
          } // end 'if'
          else
          {
            $('#new-company-form').empty();
            $.ajax({
              type: 'GET',
              url: ';addresses?company=' + ui.item.id,
              dataType: 'json',
                // process the addresses
                success: function(json) {
                  var opts = '';
                  $.each(json, function(k, v) {
                    opts += '&lt;option value="'+k+'"&gt;' + v + '&lt;/option&gt;';
                  });
                  $('#address').html('&lt;select&gt;' + opts + '&lt;/select&gt;');
                  // we click on a select value .change(function () {
                  $("#address").change(function () {
                    var id = $(":selected", this).val();
                    if(id == "create-new-address") {
                      $('#new-address-form').load(';address_form #autoform');
                    }
                    else
                    {
                      alert('Request completed' + id);
                    //  pass the id value to the application
                    }
                  }) // end click event
                }
              }); //end ajax call to address
  
          } // end else
              } // end select address
          }); // end autocomplete
      }); // end function
  &lt;/script&gt;
  </code></pre>
  
  <p>everytime i run the form, the 'alert('Request completed' + id);' on line 41 displays 4 times when i click on an option value.</p>
  
  <p>Is there any way to improve this?</p>
  
  <p>Thanks</p>
  
  <p>Norman</p>