title: Populate second and third select box after change the selected value of the first box
body: <p>Have three select boxes, at first the "device_sel" and "prob_sel" are disabled. When i choose value from the first select box, "customer_sel" i use $.post to populate device_sel. My problem is i what to do the same thing when i select value in "device_sel" then "prob_sel" populates. I think there is some error that i dont see in the $.post process when i try to populate prob_sel. When i change(or select for first time) value in device_sel, prob_sel keeps begin disabled and nothing happens.</p>
  
  <p>Can someone spot error or typeo, been trying for hour to figure this out and cant find anything. </p>
  
  <p>My javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function()
      {
          $('#device_sel').attr('disabled', true);
          $('#prob_sel').attr('disabled', true);
  
  
          $('#customer_sel').change(function()
          {
              var cid = $('#customer_sel').attr("value");
              $.post("get_customers_devices.php", {cid:cid}, function(data)
              {
                  $('#device_sel').attr('disabled', false);
                  $('#device_sel').html(data);
              });
          });
  
          $('#device_sel').change(function()
          {
              var did = $('#device_sel').attr("value");
              jQuery.post("get_device_problems.php", {did:did}, function(data)
              {
                  $('#prob_sel').attr('disabled', false);
                  $('#prob_sel').html(data);
              });
          });
  
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>get_customers_devices.php:</p>
  
  <pre><code>    &lt;?php
  
  include "FillSelect.class.php";
  
  echo $fill-&gt;FillDeviceSelect($getdata-&gt;GetCustomersDevice($_POST['cid']));
  
  ?&gt;
  </code></pre>
  
  <p>get_device_problems.php:</p>
  
  <pre><code> &lt;?php
  
  include "FillSelect.class.php";
  
  echo   $fill- &gt;FillProblemSelect($getdata-&gt;GetDeviceProblems($_POST['did'])) ;
  
  ?&gt;
  </code></pre>
  
  <p>GetCustomerDevice and GetDeviceProblems:</p>
  
  <pre><code>function GetCustomersDevice($cid)
      {
          try
           {
              $db = new PDO('sqlite:base.db') ;
              $db-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
  
              $pquery = $db-&gt;prepare("SELECT * FROM Devices WHERE cid=:cid");
              $data = array("cid"=&gt;$cid);
              $pquery -&gt; execute($data) ;
  
              $rows = $pquery-&gt;fetchAll();
  
              return $rows;
          }
          catch(PDOException $e)
          {
              echo "Failure: " . $e-&gt;getMessage();            
          }
  
          $db = NULL;
      }
  
      function GetDeviceProblems($did)
      {
          try
           {
  
              $db = new PDO('sqlite:base.db') ;
              $db-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
  
              $pquery = $db-&gt;prepare("SELECT * FROM Problems p, Devices d WHERE d.did=:did");
              $data = array("did"=&gt;$did);
              $pquery -&gt; execute($data) ;
  
              $rows = $pquery-&gt;fetchAll();
  
              return $rows;
          }
          catch(PDOException $e)
          {
              echo "Failure: " . $e-&gt;getMessage();            
          }
  
          $db = NULL;
      }
  </code></pre>
  
  <p>Finally FillDeviceSelect and FillProblemSelect:</p>
  
  <pre><code>function FillDeviceSelect($data)
      {
          $device = '&lt;option value="0"&gt;Select option&lt;/option&gt;';
          foreach($data as $row)
          {
              $device.= '&lt;option value="'. $row['did'] .'"&gt;'. $row['device_name'] .'&lt;/option&gt;';
          }
  
          return $device;
      }
  
  function FillProblemSelect($data)
      {
          $problem = '&lt;option value="0"&gt;Select option&lt;/option&gt;';
          foreach($data as $row)
          {
              $problem .= '&lt;option value="' . $row['pid']  .'"&gt;' .  $row['problem'] .'&lt;/option&gt;';
          }
  
          return $problem;
      }
  </code></pre>
  
  <p>Solved it. Very very silli mistakes, get_device_problems not in same folder as my page but i did know that the file was saved in another folder and thats why my post call didnt work...</p>