title: Pass value of Javascript variable to MySQL through PHP
body: <p>I want to pass area name selected from drop down menu to query of MySQL through PHP. I retrieved name in JavaScript but I am unable to store value from JavaScript to PHP. My Code is As follows</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;title&gt;&lt;/title&gt;
      &lt;script&gt;
          function getIndex()
          {
              var x=document.getElementById("cmbArea").selectedIndex;
              var y=document.getElementById("cmbArea").options
  
              var z= y[x].text;
              alert(z); 
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form name ="form1" action="Demo1.php" method="post"&gt;
      &lt;select id="cmbArea" name="cmbArea"&gt;
      &lt;?php
      include 'Connect.php';
      $query = "SELECT varAreaName FROM tbArea" ;
      $result = mysql_query($query);       
      while($row = mysql_fetch_assoc( $result )) { 
          echo '&lt;option value="'.$row['varAreaName'].'"&gt;' . $row['varAreaName'] . '&lt;/option&gt;';   
      }
  
      ?&gt;
      &lt;/select&gt;
      &lt;/form&gt;
      &lt;input type="Button" onclick="getIndex()" value="Alert index of selected option"&gt;
  
     &lt;/body&gt;
     &lt;/html&gt;
  </code></pre>