Welcome Guest, Not a member yet? Register   Sign In
How to create a dynamic dropdown
#1

Hello, i'm still new at codeigniter. And i'm trying to create a dynamic dropdown in my form page, while user filling the form, there will be a dynamic dropdown for user to select a certain/specific thing, once it's selected, it can be saved into the database. But when i testing it, the dynamic dropdown show nothing, how can i fix it??

The Model :

Code:
public function get_jenis_pekerjaan(){
        $query = $this->db->get('jenis_pekerjaan');
        return $query->result_array();
    }


The Controller :

Code:
public function job_type(){
        $data['jenis_pekerjaan'] = $this->m_lowongan->get_jenis_pekerjaan();
        $this->load->view('create_lowongan', $data);
    }

    public function store_lowongan(){
        $user_name          = $this->session->userdata('name');
        $title              = $this->input->post('title');
        $lokasi            = $this->input->post('lokasi');
        $level_pekerja      = $this->input->post('jenis_pekerjaan');
        $pengalaman_kerja  = $this->input->post('pengalaman_kerja');
        $pendidikan        = $this->input->post('pendidikan');
        $alamat            = $this->input->post('alamat');
        $no_wa              = $this->input->post('no_wa');
        $no_telp            = $this->input->post('no_telp');
        $min_gaji          = $this->input->post('min_gaji');
        $max_gaji          = $this->input->post('max_gaji');
        $job_desc          = $this->input->post('job_desc');
        $created_at        = date('y-m-d');
        $status            = 'draft';

        $data = array(
            'user_name'        => $user_name,
            'title'            => $title,
            'lokasi'            => $lokasi,
            'level_pekerja'    => $level_pekerja,
            'pengalaman_kerja'  => $pengalaman_kerja,
            'pendidikan'        => $pendidikan,
            'alamat'            => $alamat,
            'no_wa'            => $no_wa,
            'no_telp'          => $no_telp,
            'min_gaji'          => $min_gaji,
            'max_gaji'          => $max_gaji,
            'job_desc'          => $job_desc,
            'created_at'        => $created_at,
            'status'            => $status,
        );

        $this->m_lowongan->input_data($data, 'lowongan');
        redirect ('dashboard');
    }

The view :

Code:
<tr>
                            <td>Level Pekerjaan</td>
                            <td>
                                <select name="jenis_pekerjaan" id="jenis_pekerjaan" class="form-control">
                                  <?php foreach($jenis_pekerjaan as $l) {?>
                                    <option value="<?php echo $l['jenis_pekerjaan']?>"><?php echo $l['jenis_pekerjaan']?></option>
                                  <?php }?>
                                </select>
                            </td>
                        </tr>
Reply




Theme © iAndrew 2016 - Forum software by © MyBB