title: populate second dropdown on onchange event
body: <p>I have 3 dropdowns in my php/html page (I am using jooomla 3x and jumi to get the script files into my article) form is getting populated from MySQL database table. </p>
  
  <p>Action property in form is sending the form to second page with thank you message and sending emails to admin and users (again using jumi to achieve this). May be in can change this logic - if there is no other way (which will be long job).
  So, currently i cannot use self action event property of the form. </p>
  
  <p>I managed to populate first dropdown from MySQL Database table successfully (code below).</p>
  
  <p>I also managed to get the first dropdown selected value in div in html using jquery - but, How to cascade the same logic upon onchange event fired by first dropdown? without refreshing the whole page and loosing all the previous form selections?</p>
  
  <p>Here is my Code</p>
  
  <pre><code>      &lt;script type="text/javascript"&gt; window.onload = function(){
              document.getElementById('make').addEventListener('change',function(){
                  var $strmake = document.getElementById("make").value;
                  //alert($strmake);
                  document.getElementById("div1").innerHTML = $strmake;
              });
          }
  </code></pre>
  
  <p></p>
  
  <p>My First Drop Down working fine</p>
  
  <pre><code>                &lt;select name="make" id="make" style="font-size:1.3em;padding:5;height:40px;"&gt;
              &lt;option selected&gt;Select Make&lt;/option&gt;
              &lt;?php
                  // credentials
                  $host_name  = xxx
                  $database   = xxx
                  $user_name  = xxx
                  $password = xxx
  
  
                  $connect = mysqli_connect($host_name, $user_name, $password, $database) or die("Error " . mysqli_error($connect));
                  if (mysqli_connect_errno())
                  {
                      echo "Failed to connect to MySQL: " . mysqli_connect_error();
                  }
                  else {
                      echo "Connected to MySQL&lt;br&gt;";
                  }
  
                  //execute the SQL query and return records
                  $query = "SELECT distinct make FROM VehicleModelYear ORDER BY make";
  
                  $result = mysqli_query($connect, $query); 
  
                  //fetch tha data from the database 
                  while($row = mysqli_fetch_array($result)) { 
                    echo "&lt;option value='" . $row['make'] . "'&gt;" . $row['make'] . "&lt;/option&gt;"; 
                  } 
              ?&gt;
              &lt;/select&gt;
  </code></pre>
  
  <p>Second drop down code</p>
  
  <pre><code>                &lt;SELECT name="model" class="" id="model" style="font-size:1.3em;padding:5;height:40px;"&gt;
              &lt;OPTION selected&gt;Select Model&lt;/OPTION&gt;
              &lt;?php
  
                  $connect = mysqli_connect($host_name, $user_name, $password, $database) or die("Error " . mysqli_error($connect));
                  if (mysqli_connect_errno())
                  {
                      echo "Failed to connect to MySQL: " . mysqli_connect_error();
                  }
                  else {
                      echo "Connected to MySQL&lt;br&gt;";
                  }
  
                  $selected = explode(',', $_POST['make']);
                  $s_id = $selected[0];
                  $s_name = $selected[1];
  
                  //execute the SQL query and return records
                  $query = "SELECT distinct model FROM VehicleModelYear where ????? ORDER BY model";
  
                  $result = mysqli_query($connect, $quer2); 
  
                  //fetch tha data from the database 
                  while($row = mysqli_fetch_array($result)) { 
                    echo "&lt;option value='" . $row['model'] . "'&gt;" . $row['model'] . "&lt;/option&gt;"; 
                  } 
              ?&gt;
              &lt;/SELECT&gt;
  </code></pre>
  
  <p>Hopefully I will achieve the third on if I have the solution for the second one?</p>
  
  <p>Thanks in advance...</p>