php - How to pass value to the second page using Javascript AJAX -


i have html select on page

<pre> $query = mysql_query("select * results"); echo "<select id='date' onchange='showdata()' class='form-control'>"; while ($arr = mysql_fetch_array($query)) { echo "<option value=".$arr['month'].">".$arr['month']." / ".$arr['year']. "</option>" ;    } echo "</select>"; </pre> 

the options coming database. after have ajax script

<script>  function showdata() {   var xhttp = new xmlhttprequest();   xhttp.onreadystatechange = function() {     if (this.readystate == 4 && this.status == 200) {      document.getelementbyid("demo").innerhtml = this.responsetext;     }   };    xhttp.open("get", "result.php", true);   xhttp.send(); }  </script> 

i want send selected value in html select page result.php

another way of doing same thing using jquery ajax ...

<select id="item" onchange="send_item(this.value)">  <?php $somevariable = $_get["somevariable"];        $query = mysql_query("select * results");        echo "";      while ($arr = mysql_fetch_array($query)) {?> <option value="<?php echo value?>"><?php echo value?></option>    <?php }?> </select>      <script>   function send_item(str){     $.ajax({         url: '',         type: "post",         data: {            'str':str,         },         success: function(data) {          },     });  }     </script> 

Comments