title: Populate 2 dropdowns from jquery change event
body: <p>I have a change event that on it's own works well. However, what I am trying to do is, on the change event, update 2 different divs with using 2 different $.get calls to php. For example, user selects company name. This is stored in a global variable of <code>value</code>. I then need to query 2 different queries in mysql and place the results in 2 different divs. </p>
  
  <p>I know this code is never going to workas is, so I need guidance from the experts. </p>
  
  <p>This is difficult to explain so hopefully the code will shed some light on it. If you need anymore information, please let me know. Many thanks</p>
  
  <pre><code>$(function() {
    $(document).on('change', '.rtvcompany', function() {
      value = $(this).val();
      $(this).after('&lt;div id="loader"&gt;&lt;img src="/domain/admin/images/loader.gif" alt="loading files" /&gt;&lt;/div&gt;');
      $.get('/domain/admin/requests/boxes/retrieve/loadboxRtvcompany.php?rtvcompany=' + value, function(data) {
        console.log(value);
        $(".rtvdept").html(data);
        $('#loader').slideUp(200, function() {
          $(this).remove();
          $(".rtvdept").val('');
          $(".rtvdept").attr("data-placeholder", "Select your department");
          $(".rtvdept").trigger("chosen:updated");
        });
      });
    });
  });
  
  $(function() {
        $(document).on('change', '.rtvdept', function() {
          value = $(this).val();
          $(this).after('&lt;div id="loader"&gt;&lt;img src="/domain/admin/images/loader.gif" alt="loading files" /&gt;&lt;/div&gt;');
          $.get('/domain/admin/requests/boxes/retrieve/loadboxRtvaddr.php?rtvaddr=' + value, function(data) {
            $("#address").html(data);
            $('#loader').slideUp(200, function() {
              $(this).remove();
              //console.log(data);
              $("#address").val('');
              $("#address").attr("data-placeholder", "Select your address");
              $("#address").trigger("chosen:updated");
            });
          });
        });
      });
  
      $(function() {
        $(document).on('change', '.rtvdept', function() {
          //value = $(this).val();
          $(this).after('&lt;div id="loader"&gt;&lt;img src="/domain/admin/images/loader.gif" alt="loading files" /&gt;&lt;/div&gt;');
          $.get('/domain/admin/requests/boxes/retrieve/loadboxRtvbox.php?rtvbox=' + value, function(data) {
            //console.log(value);
            $("#box_rtv").html(data);
            $('#loader').slideUp(200, function() {
              $(this).remove();
              //console.log(data);
              $("#box_rtv").val('');
              //$("#box_rtv").attr("data-placeholder", "Select your new box");
              $("#box_rtv").trigger("chosen:updated");
            });
          });
        });
      });
  </code></pre>