I want to create multiple drop down list in codeigniter, in my case when the user selects country the next list should provide the state options of that country and after the user selects the state the next section should provide the town options etc... I want the list or options to be provided by using some scripts, and when the user finally completes the selection the list should be updated in the database. Is it possible to provide the list of options by using scripts instead of loading the options from the database. Here is the view and model file on which I want to implement the dynamic drop down list
form_model.php
function r_ins()
{
$session_user=$this->session->userdata('logged_in');
$sysdat = date("Y-m-j H:i:s");
$data= array(
'id' => $this->input->post('id'),
'name' => $this->input->post('name'),
'country' => $this->input->post('country'),
'state' => $this->input->post('state'),
'town' => $this->input->post('town'),
'village' => $this->input->post('village'),
'c_name' => $session_user['username'],
'c_date' => $sysdat
);
$this->db->insert('r_info',$data);
return $this->input->post('id');
//echo "<pre>";
// print_r($_POST);
}
view.php
<label> ID:<span id="r_id" style="font-size:12px;float:right;"></span></label>
<input type="text" name="id" id="r_id" placeholder="ID" required/>
<label >Name:</label>
<input type="text" name="name" placeholder="Name" required/>
<label >Country:</label>
<select name="country" >
<option>Select Country</option>
<option value="USA">USA</option>
<option value="AUS">Austrailia</option>
<option value="Jap">Japan</option>
<option value="Korea">Korea</option>
</select><br/><br/>
<label >State:</label>
<input type="text" name="state" placeholder="State" required/>
<label >City:</label>
<input type="text" name="city" placeholder="City" required/>
<label >Town:</label>
<input type="text" name="town" placeholder="Town" required/>
<input type="submit" value="Save" id="re_submit" class="button"><br/>
</form>