Jquery -> ビュー -> v_addEmployee::
function get_subdepartment() {
var dep_selected = $('select[name=txtDept]').val();
$.ajax({
data: {
dept: dep_selected,
},
type: 'POST',
url: 'addEmployee/getSubDept',
success: function(data){
console.log(data);
alert(dep_selected);
$('.subDept').html(data);
}
})
}
表示 -> v_addEmployee:
$rs_dept = $this->m_addVacancy->getDepartment();
$deptOption['-'] = 'Select Department';
if ($rs_dept){
foreach($rs_dept as $row_dept){
$deptOption[$row_dept->dept] = $row_dept->dept;
}
}
//echo form_dropdown($name = 'txtDept',$Options = $department, array($this->input->post('txtDept')) ,'class="txt2" style="width: 96% " onChange="get_subdepartment1();"');
echo form_dropdown('txtDept',$deptOption, array($this->input->post('txtDept')),'class="txt2" style="width: 96% " onChange="get_subdepartment();" onSelect="get_subdepartment();"');
コントローラ: addEmployee/getSubDept に存在するかどうか addEmployee/index
function index(){
$this->load->helper('form');
$this->load->view('v_addEmployee');
}
function getSubDept(){ echo $this->input->post(dept); }
.subDept では addEmployee/index ページを表示しています。助けてください