title: Updating one drop down menu according to option selected in another drop down menu from database
body: <p><strong>EDITED AFTER SUGGESTIONS (STILL UNRESOLVED):</strong> </p>
  
  <p>I have 2 drop down menu's, one called Country, and the other called City. When the user chooses a country from the Country drop down menu (hereafter a drop down menu will be referred to as a DDM for brevity), I want the City DDM to show all the cities in that particular country.</p>
  
  <p>I have a <strong>relation (called location</strong>) in the database of the following simple form (with some entries):</p>
  
  <pre><code>id country city
      1  India  New Delhi
      2  India  Hyderabad
      3   USA    San Diego
      4   USA    Palo Alto
  </code></pre>
  
  <p>This is the code I wrote : </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Admin Page&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/
  ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
      $(document).ready(function()
      {
          $(".country").change(function()
          {
              var country=$(this).val();
              var dataString = 'country='+ country;
              alert(dataString);
              $.ajax
              ({
                  type: "POST",
                  url: "getcity.php",
                  data: dataString,
                  dataType : html,
                  cache: false,
                  success: function(data, textStatus)
                  {
                      alert(textStatus);
                      $(".city").html(data);
                  } 
              });
  
          });
      });
  &lt;/script&gt;
  
  &lt;body&gt;
  
  &lt;br /&gt;
  &lt;legend&gt;&lt;h2&gt;Welcome Admin!&lt;/h2&gt;&lt;/legend&gt;
  
  
  &lt;?php
  include('db.php');
  
  $sql="SELECT distinct country FROM location"; 
  $result=mysqli_query($con, $sql); 
  
  if (!$result)
  {
      echo "DB Error, could not list tables\n";
      echo 'MySQL Error: ' . mysql_error();
      exit;
  }
  
  echo '&lt;h4&gt;Location :&lt;/h4&gt;';
  echo '&lt;select name="loaction" class="location"&gt;';
  echo '&lt;option value="foo"&gt;'.'Choose Country'.'&lt;/option&gt;';
  while ($row=mysqli_fetch_array($result))
  {
      echo '&lt;option value='.$row[country].'&gt;'.$row[country].'&lt;/option&gt;';
  }
  echo '&lt;/select&gt;';
  
  ?&gt;
  
  &lt;h4&gt;&lt;label&gt;City :&lt;/label&gt; &lt;/h4&gt;
  &lt;select name = 'city' class = 'city'&gt;
      &lt;option value = 'foo' &gt; Choose City &lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I hope you have taken the trouble to scroll down and see the above code. The file getcity.php is as follows :</p>
  
  <pre><code>&lt;?php
  include('db.php');
  
  if($_POST['country'])
  {
      $country=$_POST['country'];
      $sql=mysql_query("select id, city from location where country='$country'");
  
      while($row=mysql_fetch_array($sql))
      {
          $id=$row['id'];
          $city=$row['city'];
          echo '&lt;option value="'.$id.'"&gt;'.$city.'&lt;/option&gt;';
      }
  }
  </code></pre>
  
  <p>However, I cannot see anything in the City DDM even after the status returned from the AJAX call (seen through alert()) is a 'Success'.</p>
  
  <p>What am I missing? </p>
  
  <p>Thanks again.</p>