我在杂货店中有2个下拉字段,一个是选择项目,另一个是选择单位,我可以使一个字段依赖于另一个吗?我选择项目时的示例,单位选择中唯一可用的选项是仅在数据库中的所选项目中分配的单位。感谢。
$crud = new grocery_CRUD();
$crud->set_subject('Release Item');
$crud->set_table('dept_release');
$crud->set_relation('departments_id','departments','name');
$crud->set_relation('destination_id','destination','name');
$query = $this->db->query("select id,name from items where type=0");
if($query->num_rows() > 0){
foreach ($query->result_array() as $key => $v) {
$item_list[$v['id']] = $v['name'];
};
$crud->field_type('item', 'dropdown', $item_list);
}
$crud->field_type('users_id', 'hidden', $this->session->userdata('id'));
$crud->field_type('unit', 'dropdown', array(null => 'Please select a unit'));
$crud->field_type('sy_id', 'hidden', $this->session->userdata('sy_id'));
$crud->unset_read();
$output = $crud->render();
$this->_unit_output($output,"Units");
答案 0 :(得分:0)
select * from tbl where id=[id]
绑定id并将dropdownlist放在changeevent上,
并根据结果绑定其他下拉列表。
答案 1 :(得分:0)
$results = $this->db->query('select distinct tahap_penyusunan from m_penyusunan_proleg proleg order by id_penyusunan_proleg')->result();
$employees_multiselect = array();
foreach ($results as $result) {
$employees_multiselect[$result->tahap_penyusunan] = $result->tahap_penyusunan;
}
->field_type('penyusunan', 'dropdown',$employees_multiselect)