title: Dependent drop down displaying value id instead of displaying name on post submit
body: <p>I have 3 columns</p>
  
  <ol>
  <li>Country (id, country_name)</li>
  <li>State (id, country_id, state_name)</li>
  <li>files_dev (id,country_name,state_name)</li>
  </ol>
  
  <p>Country and State i am using  onchange event handler to select element, then have it fire off an AJAX request to my PHP script every time the user selects country it will show related state names.</p>
  
  <p>Problem is on POST SUBMIT i want to insert country name instead of its value id</p>
  
  <p>This is the code i am using</p>
  
  <pre><code>&lt;?php
          if ($country_result-&gt;num_rows &gt; 0) {
          // output data of each row
          while($row = $country_result-&gt;fetch_assoc()) {
  ?&gt;
      &lt;option value="&lt;?php echo $row["id"]; ?&gt;"&gt;
  &lt;?php echo $row["country_name"]; ?&gt;&lt;/option&gt;&lt;?php
  </code></pre>
  
  <p>I tried changing the $row["id"] to $row["country_name"], Any help here would be highly appreciated</p>
  
  <p>index.php</p>
  
  <pre><code>&lt;form class="form-horizontal" method="post" id="signin" enctype="multipart/form-data"&gt;
  
                              &lt;div class="control-group"&gt;
                                      &lt;label class="control-label" for="inputPassword"  placeholder="Select Gram Panchayat" &gt;&lt;strong&gt;Select Gram Panchayat&lt;/strong&gt;&lt;/label&gt;
                                          &lt;div class="controls"&gt;
                                          &lt;?php
                                          require_once('../admin/lib/db.php');
                                          $country_result = $conn-&gt;query('select * from countries');
                                          ?&gt;
                                              &lt;select name="country" class="chzn-select" id="countries-list" required&gt;
  
                                          &lt;?php
                                              if ($country_result-&gt;num_rows &gt; 0) {
                                          // output data of each row
                                          while($row = $country_result-&gt;fetch_assoc()) {
                                              ?&gt;
                                              &lt;option value="&lt;?php echo $row["id"]; ?&gt;"&gt;&lt;?php echo $row["country_name"];?&gt;&lt;/option&gt;
                                              &lt;?php
  
                      echo "&lt;option value='". $row['id']."'&gt;".$row['country_name'] .'&lt;/option&gt;';
  
                                          }
  
                                      }
                                      ?&gt;
                                              &lt;/select&gt;
                                      &lt;/div&gt;
                            &lt;/div&gt;
  
                                      &lt;div class="control-group"&gt;
                                      &lt;label for="inputPassword" class="control-label"  placeholder="Select Village" &gt;&lt;strong&gt;&lt;strong&gt;Select Village&lt;/strong&gt;&lt;/strong&gt;&lt;/label&gt;
                                          &lt;div class="controls"&gt;
                                              &lt;select name="state" id="states-list" required&gt;
  
  
                                              &lt;/select&gt;
                                          &lt;/div&gt;
                            &lt;/div&gt;
  
                                              &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"&gt;&lt;/script&gt;
                                              &lt;script&gt;
                                      $('#countries-list').on('change', function(){
                                          var country_id = this.value;
                                          $.ajax({
                                          type: "POST",
                                          url: "village_dev.php",
                                          data:'country_id='+country_id,
                                          success: function(result){
                                              $("#states-list").html(result);
                                          }
                                          });
                                      });
                                      &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <p>village_dev.php</p>
  
  <pre><code>    &lt;?php
     require_once('../admin/lib/db.php');
     error_reporting(0);
     $country_id = mysql_real_escape_string($_POST['country_id']);
     if($country_id!='')
     {
      $states_result = $conn-&gt;query('select * from states where country_id='.$country_id.'');
      $options = "&lt;option value=''&gt;Select Village&lt;/option&gt;";
      while($row = $states_result-&gt;fetch_assoc()) {
      $options .= "&lt;option value='".$row['state']."'&gt;".$row['state']."&lt;/option&gt;";
      }
      echo $options;
     }
  
     ?&gt;
  </code></pre>
  
  <p>Let me know if i am missing anything here, i want to submit the value name not the id to the database.</p>