title: How do you retrieve values from an Ajax drop down list from a different page? PHP
body: <p>I have successfully created some cascading dropdown lists, but I cannot seem to retrieve the values. The dropdown lists are entirely created on another page, and I don't know why, but I just assumed that it would pull the select name and selected value from the lists as well. When I print_r($_REQUEST), there is no information at all from the secondary and third dropdowns.</p>
  
  <p>The first page is just a plain ol' form, like this:</p>
  
  <pre><code>&lt;center&gt;&lt;div id="country"&gt;&lt;b&gt;Country&lt;/b&gt;&lt;/div&gt;&lt;/center&gt;
  &lt;/td&gt;&lt;td&gt;&lt;center&gt;&lt;div id="province"&gt;&lt;b&gt;Province&lt;/b&gt;&lt;/div&gt;&lt;/center&gt;
  &lt;/td&gt;&lt;td&gt;
  </code></pre>
  
  <p>This is the JavaScript</p>
  
  <pre><code>function showRecords(str,column,nextDiv)
  {
  if (str=="")
    {
  
    document.getElementById(nextDiv).innerHTML="";
    return;
    }
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
      {
  
      document.getElementById(nextDiv).innerHTML=xmlhttp.responseText;
      }
    }
  xmlhttp.open("GET","getRecords.php?"+column+"="+str,true);
  xmlhttp.send();
  }
  </code></pre>
  
  <p>This is the page that it is pulling dropdowns from</p>
  
  <pre><code>&lt;?
  require "functions.php";
  
  
  if(isset($_REQUEST['region'])){
      $region=$_REQUEST['region'];
      getDepRecords("country","regions","region",$region,"province");
      }
  
  if(isset($_REQUEST['country'])){
  
      $country=$_REQUEST['country'];
      getDepRecords("province","countries","country",$country,"");
  }
  ?&gt; 
  </code></pre>
  
  <p>This is the specific function</p>
  
  <pre><code>function getDepRecords($column, $table, $depColumn, $dep, $nextDiv) {
      echo "&lt;select name =".$column." id=".$column." 
      onchange=\"showRecords(this.value,'".$column."','".$nextDiv."')\"&gt;\n";
      $options = "";
      if (isset($_REQUEST)) {
          $selected = $_REQUEST[$column];
      }
      $query = "SELECT DISTINCT $column FROM $table WHERE 
      $depColumn = \"$dep\" ORDER BY $column ASC";
      $result = mysql_query($query);
      if (!$result) {
          $options = "&lt;option&gt;Error Retrieving Records&lt;/option&gt;\n";
      }
      else {
        $options.= "&lt;option value = ".NULL."&gt;Select ".$column."&lt;/option&gt;\n";
        $options.= "&lt;option value = ".NULL."&gt;&lt;/option&gt;\n";
          while ($row = mysql_fetch_assoc($result)) {
              $value = $row[$column];
              $options.= "&lt;";
              $options.= "option value=\"";
              $options.= $value . "\"";
              if (isset($selected)) {
                  if (($selected) == ($value)) {
                      $options.= " selected";
                  }
                  $options.= "";
              }
              $options.= "&gt;";
              $options.= $value;
              $options.= "&lt;/option&gt;\n";
          }
  
      }
      echo $options;
      echo "&lt;/select&gt;";
  } 
  </code></pre>