the data corresponding to the id is getting.but cannot place to the text fields. i want to place data corresponding to that id in the text fields.anybody can help.its not getting Controller
public function addrfqoffline() {
$this->load->helper(array('form', 'url'));
$this->load->view('moderator/templates/header');
$this->load->view('moderator/templates/sidebar');
$rid=$this->input->post('reqid');
echo $rid;
$requirement=$this->requirement_model->viewdata($rid);
$data['customers']=$this->userdata->usersname();
$data['merchants']=$this->merchant_model->merchantname();
// $data['mroproducts']=$this->mroproduct_model->mroproductname();
$data['units']=$this->requirement_model->fetchunits();
if($requirement)
{
foreach ($requirement as $reqdata) {
$dat['reqid'] = $reqdata->rqm_id;
$dat['service'] = $reqdata->rqm_service;
$this->load->view('moderator/mrorfqnew',array_merge($dat,$data));
}
}
$this->load->view('moderator/mrorfq',$data);
$this->load->view('moderator/templates/footer');
}
view
<div class="col-xs-6">
<label for="txtname">Title of Quotation Request :</label>
<input type="text" name="txtTitle" class="form-control" id="txtname" value="<?php if(!empty($reqid)){echo $reqid;} ?>" required>
</div>`enter code here`
model
public function viewdata($reqid) {
$this->db -> select('*');
$this -> db -> from('jil_requirements');
$this -> db -> where('rqm_id',$reqid);
$query = $this -> db -> get();
return $query->result();
}
ajax
<script>
function getValue(val) {
//alert(val);
$.ajax({
type: "POST",
url: "<?php echo base_url()?>moderator/RFQ/addrfqoffline",
data:'reqid='+val,
success: function(data){
alert(data);
$("#txtproduct").html(data);
}
});
}
</script>
First create an empty div in the page where you want to display the content.
<div id="content"></div>
Next, change your controller function like this
function addrfqoffline() {
$content = "";
$this->load->helper(array('form', 'url'));
$content = $this->load->view('moderator/templates/header','',true);
$content .= $this->load->view('moderator/templates/sidebar','',true);
$rid = $this->input->post('reqid');
$requirement = $this->requirement_model->viewdata($rid);
$data['customers'] = $this->userdata->usersname();
$data['merchants'] = $this->merchant_model->merchantname();
// $data['mroproducts']=$this->mroproduct_model->mroproductname();
$data['units'] = $this->requirement_model->fetchunits();
if ($requirement) {
foreach ($requirement as $reqdata) {
$dat['reqid'] = $reqdata->rqm_id;
$dat['service'] = $reqdata->rqm_service;
$content .= $this->load->view('moderator/mrorfqnew', array_merge($dat, $data),true);
}
}
$content .= $this->load->view('moderator/mrorfq', $data,true);
$content .= $this->load->view('moderator/templates/footer',true);
echo $content;// this will echo the view here
}
Now in ajax success,
success: function(data){
$("#content").html(data);
}
This should help you.