I want to know how I can pass the value of input textbox into php variable without button and refresh of page, because I want to pass the value into controller and model. I'm using CodeIgniter.
This is just an example.
Controller.php
class Home extends CI_Controller {
public function main(){
$entry_id = $this->input->post('entry_id');
$datas['query'] = $this->model->samplemodel($entry_id);
$this->load->view('sampleview',$datas);
}
}
.
Model.php
class Model extends CI_Model{
public function samplemodel(entry_id){
$this->load->database();
$this->db->select("fullname");
$this->db->where('entry_id',entry_id);
$query = $this->db->get('position');
return $query->result();
}
}
.
sampleview.php
<input type="textbox" name="id">
<?php
foreach($query as $row){
echo $row->fullname;
}
?>
. Output will be...
grace
paul
mang juan
Every time you change the value of input textbox the output will be change.