title: Chained dropdown list in codeigniter
body: <p>I want to create multiple drop down list in codeigniter, in my case when the user selects center the next list should provide the co-ordinater options of that center. Is it possible to provide loading the options from the database. </p>
  
  <p><strong>view</strong> </p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;label class="control-label col-lg-2"&gt;Select Center&lt;span class="text-danger"&gt;*&lt;/span&gt; &lt;/label&gt;
      &lt;div class="col-lg-9"&gt;
          &lt;select name="center" class="form-control required"&gt;
              &lt;option value=""&gt;Choose an option&lt;/option&gt;
          &lt;/select&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label class="control-label col-lg-2"&gt;Co-ordinator&lt;span class="text-danger"&gt;*&lt;/span&gt; &lt;/label&gt;
      &lt;div class="col-lg-9"&gt;
          &lt;select name="co-ordinator" class="form-control required"&gt;
              &lt;option value=""&gt;Choose an option&lt;/option&gt;
          &lt;/select&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>controller</strong></p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  class House extends CI_Controller 
  {
  
      public function __construct()
      { 
          parent::__construct();
          $this-&gt;load-&gt;helper('url');
          $this-&gt;load-&gt;model('admin/Hose_model');
          $this-&gt;load-&gt;library('session');
      }
  
      public function index()
      {   
          $dis['res']=$this-&gt;Hose_model-&gt;display()-&gt;result_array();
          $this-&gt;load-&gt;view('admin/house',$dis);
      }
      public function add()
      {            
           $data['center']=$this-&gt;input-&gt;post('center');
           $data['co-ordinator']=$this-&gt;input-&gt;post('co-ordinator');
           $this-&gt;Hose_model-&gt;db_insert($data);
           redirect("admin/house");
           $this-&gt;load-&gt;view('admin/newhouse');               
      }  
  }
  </code></pre>
  
  <p><strong>model</strong> </p>
  
  <pre><code>public function db_insert($data)
  {
      $query=$this-&gt;db-&gt;insert('hose_db',$data);
      return $query;
  }
  </code></pre>