title: populate dropdown list based on previous form inputs and data from MySQL
body: <p>I have a form which asks customer for some details. I want the final dropdown list to be populated based on the inputs from the customer. The data for this dropdown list is taken from MySql database using PHP. here is the code i have prepared but it does not seem to work.</p>
  
  <p>Form code:</p>
  
  <pre><code>               &lt;tr&gt;  
                  &lt;td&gt;&lt;label&gt;Trade:&lt;/label&gt;&lt;/td&gt;
                  &lt;span class="text_11"&gt;
                  &lt;td&gt;&lt;input type="radio" id="Buy" name="tradetype" class="listen" required value="Buy"/&gt;&lt;radio style="font-size: 16px;"&gt; Buy&lt;/radio&gt;
                  &lt;input type="radio" id="Sell" name="tradetype" class="listen" value="Sell"/&gt;&lt;radio style="font-size: 16px;"&gt; Sell &lt;/radio&gt;&lt;/span&gt;&lt;/td&gt;
             &lt;/tr&gt;
             &lt;tr&gt;  
                  &lt;td&gt;&lt;label&gt;Item:&lt;/label&gt;&lt;/td&gt;
                  &lt;span class="text_11"&gt;
                  &lt;td&gt;&lt;input type="radio" id="Cloth" name="item" class="listen" required value="Cloth"/&gt;&lt;radio style="font-size: 16px;"&gt; Cloth&lt;/radio&gt;
                  &lt;input type="radio" id="Fruit" name="item" class="listen" value="Fruit"/&gt;&lt;radio style="font-size: 16px;"&gt; Fruit&lt;/radio&gt;&lt;/span&gt;&lt;/td&gt;
             &lt;/tr&gt;
              &lt;tr&gt;  
                  &lt;td class="select"&gt;&lt;label&gt;Date:&lt;/label&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;select id="exdate" name="date1"&gt;
                  &lt;option value="2"&gt;Select&lt;/option&gt;
                  &lt;?php include_once "selectdate.php"?&gt;&lt;/td&gt;
                  &lt;/select&gt;
             &lt;/tr&gt; 
             &lt;tr&gt;  
                  &lt;td class="select"&gt;&lt;label&gt;Amount:&lt;/label&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;select id="noselect" name="noselect"&gt;
                  &lt;option value="1"&gt;Select&lt;/option&gt;
                  &lt;option value="1"&gt;Choose Item&lt;/option&gt;
                  &lt;/select&gt;
             &lt;/tr&gt; 
  </code></pre>
  
  <p>The Amount dropdownlist must be populated with data from MySQL based on the Trade, Item and the Date.</p>
  
  <p>here is my jquery for this:</p>
  
  <pre><code>$(document).ready(function () {
  
  $('#exdate').change(function () {
  
      var tradetype = $('[name="tradetype"]:checked').val();
      var date = $('select[name=date1]').val()
      var item = $('[name="item"]:checked').val();
  
      $('#confirm_tradetype').text(tradetype);
      $('#confirm_date1').text(date1);
      $('#confirm_item').text(item);
  
      $.ajax({
          type: "POST",
          url: "selectamount.php",
          data: {
                  "tradetype": tradetype,
                  "item": item,
                  "date1": date1,
          },
          success: function (data) { 
          var source = 
          {
              datatype: "json",
              datafields: 
              { name: 'Amount'},
              url: 'selectamount.php'
          };
          var dataAdpater = new $.jqx.dataAdapter(source);
          $("#noselect").jqxDropDownList(
          {
          source: dataAdapter,
          displayMember: 'Amount',
          valueMember: 'Amount',
          });
      }
      });
    });
    });
  </code></pre>
  
  <p>and here is the php query (selectamount.php)</p>
  
  <pre><code>&lt;?php
  include_once "connect.php";
  $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); 
  
  $form=$_POST;
  $trade=$form['tradetype'];
  $date1=$form['date1'];
  $item=$form['item'];
  
  $stmt = $conn-&gt;query("SELECT Amount FROM Contracts WHERE Trade='$trade' AND Item='$item' AND Date='$date1' ORDER BY Amount ASC"); 
  while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC)) {
     echo json_encode($row);
  }
  
  $conn-&gt;db=null;
  ?&gt;
  </code></pre>