title: How to set onchange of two dropdown in JQuery & CodeIgniter
body: <p>I'm using CodeIgniter and I have a question in setting onchange on two dropdown using JQuery,
  here is the code :</p>
  
  <pre><code>&lt;?
  function generateSelect($name = '', $options = array(), $code) {
      $html = '&lt;select name="'.$name.' id="'.$name.'""&gt;';
      foreach ($options-&gt;result_array() as $row) {
          if ($row[$name] == $code) {
          $html .= '&lt;option value='.$row[$name].' selected&gt;'.$row[$name].'&lt;/option&gt;';
          } else {
          $html .= '&lt;option value='.$row[$name].'&gt;'.$row[$name].'&lt;/option&gt;';
          }
      }
      $html .= '&lt;/select&gt;';
      return $html;
  }
  
  echo '&lt;div id="actype"&gt;&lt;table cellpadding=2 cellspacing=2 border=1&gt;&lt;tr&gt;&lt;td&gt;AC TYPE&lt;/td&gt;&lt;td&gt;'.generateSelect('actype', $query_1, $actype).'&lt;/td&gt;';
  
  echo '&lt;div id="acreg"&gt;&lt;tr&gt;&lt;td&gt;AC REG&lt;/td&gt;&lt;td&gt;'.generateSelect('acreg', $query_2, $acreg).'&lt;/td&gt;&lt;/div&gt;&lt;/table&gt;';
  ?&gt;
  </code></pre>
  
  <p>And this is the javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;      
  $(function() {           
  // navigate to page on click event           
  $('#actype').bind('change', function() { goToPage(); } );      
  $('#acreg').bind('change', function() { goToPage(); } );      
  });       
  
  function goToPage() {
  location.href = 'http://localhost/CAMP/CI/index.php/blog/show_package/'+$("#actype :selected").val()+'/'+$("#acreg :selected").val();
  } 
  &lt;/script&gt; 
  </code></pre>
  
  <p>So when the first dropdown is selected, the page will add some uri segment. 
  And based on that segment, some query will run and then list of second dropdown is generated.</p>
  
  <p>The problem is when the second dropdown is selected, the page adds "undefined" as new segment. I think the page cannot fetch the selected value of second dropdown.</p>
  
  <p>Please Help.</p>