hi i have a problem when i pass the button value... when i click the button i want to show the detail depends on the button but i guess button value doesnt pass from view to controller. help,,,
//view(button)
<div class="marketer">
<?php foreach($marketer_list as $marketer){ ?>
<button type="button" class="mid" name= "posting_user_id" value="<?=$marketer->id?>"><?=$marketer->username?></button>
<?php }?>
</div>
$(document).ready(function () {
$('.mid').click(function(){
var id = $(this).attr('value');
alert(id);
if (id=='<?=$detail->posting_user_id?>')
{
$(".show_posting").show();
}else{
alert("no info");
}
});
});
//controller
$posting_user_id = $this->input->post('posting_user_id');
$data['daily'] = $result;
$data['posting'] = $this->posting_models->get_manage_hospital_list($posting_user_id);
$this->load->view('posting',$data);
//model
function get_manage_hospital_list($posting_user_id){
$this->db->select('u.hosp_name,p.*');
$this->db->from('users as u');
$this->db->join('posting_plan as p', 'u.id=p.hospital_id');
$this->db->where('posting_user_id',$posting_user_id);
$this->db->order_by('p.report_day','asc');
return $this->db->get()->result();
}
You haven't put an id for the button which has a class called 'mid'. Don't forget to put a unique id there. Also you have to check whether $detail->posting_user_id has a value in the view.