I am new to CodeIgniter, so I dont know how to do this. I want to display values dynamically in a select box and after selecting the value it displays a textbox and then it then pass the textbox value and and the option( the names which is displayed on dropdown list) id to controller,so briefly what I want to do:
- dynamically show the values in select box
- after selecting the value dynamically create textBox
- passing the selected or track the 'id' of dropdown list and textbox value to controller
here is my Model
function getAllCategories(){
$this->db->select('cat_name');
$q = $this->db->get('category');
if ($q->num_rows() > 0){
foreach($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
my controller
function showCategoryNames(){
$data = array();
$this->load->model('categoryModel');
$query = $this->categoryModel->getAllCategories();
if ($query){
$data['records'] = $query;
}
$this->load->view('itemsView',$data);
}
View: this is showing the simple list
<?php if(isset($records)) : foreach($records as $row) :?>
<h2><?php echo $row->cat_name; ?></h2>
<?php endforeach;?>
<?php else :
endif;?>