title: AJAX/PHP - populate different types of input fields with one ajax call
body: <p>I figured how to populate a text box via AJAX. I was also able to populate a dropdown select box from AJAX. But I can't seem to populate text boxes and select boxes at the same time from one AJAX call. </p>
  
  <p>Here's a recreation of what I have:</p>
  
  <pre><code>&lt;?php echo "
  &lt;script type="text/javascript" language="javascrpt"&gt;$(document).ready(function(){ 
          $('#test').change(function() {
              $.ajax({
                  url:"myurl",
                  type:"POST",
                  dataType: "json",
                  data: {test: $(this).val()},
                  success:function(data)
                  {
                      $('#team1').val(data["team1"]);
                      $('#team2').val(data["team2"]);
                      $('#team_member1').val(data["g1"]);
                  }
              });
          });
  });
  &lt;/script&gt;
  
  &lt;select name='test' id='test'&gt;
    &lt;option value='1'&gt;&lt;/option&gt;
    &lt;option value='2'&gt;&lt;/option&gt;
    &lt;option value='3'&gt;&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;input type='text' name='team1' id='team1' value='".$t1."'&gt;
  &lt;select name='team_member1 id='team_member1'&gt;
    &lt;option value='".$output."'&gt;&lt;/option&gt; &lt;!--!!HELP HERE!!--&gt;
  &lt;/select&gt;
  
  &lt;input type='text' name='team2' id='team2' value='".$t2."'&gt;
  </code></pre>
  
  <p>myurl.php</p>
  
  <pre><code>&lt;?php
  $con = mysqli_connect("localhost","root","root","local");
  $output='';
  
  $sql = "SELECT name FROM team WHERE id='".$_POST["test"]."'";
  $result = $con-&gt;query($sql);
  
  while($row = $result-&gt;fetch_assoc())
  {
      $output .= '&lt;option value="'.$row['name'].'"&gt;'.$row['name'].'&lt;/option&gt;';
  }
  
  
  $t1='Boston Falcons';
  $t2='Human Resources';
  
  $response = array(
      "team1" =&gt; $t1,
      "team2" =&gt; $t2,
      "g1"=&gt;$output, &lt;---mysql resultset for dropdown not working
      );
      echo json_encode($response);
  ?&gt;
  </code></pre>
  
  <p>Upon changing <code>#test</code>,AJAX is able to pre populate <code>#team1</code> and <code>#team2</code>  text fields with their respective strings from <code>myurl.php</code>. </p>
  
  <p>However, it doesnt pre populate <code>#team_member1</code> with a list of options <code>$output</code> (mysql result set) though.</p>
  
  <p>Thanks in advance.</p>