链式下拉Codeigniter(第三个下拉按钮无效)

时间:2019-10-12 12:11:26

标签: php codeigniter dropdown chained

请帮我解决问题。我只是想从第三个下拉列表中获取数据。从表中检索第一个下拉菜单,第二个下拉菜单与第一个下拉菜单链接。但是我无法获得第二个下拉列表的ID来显示第三个dropwdown上的数据。我不知道为什么,第二个下拉菜单和第三个下拉菜单之间的代码也相同。
比方说:第一个下拉列表是Bidang,第二个下拉列表是Proker,第三个下拉列表是Kegiatan。
这是代码:
控制器

find_all()

查看

public function add()
{
    $data['controller'] ="feed";
    $data['option_bidang'] = $this->MChain->getBidangList();
    $this->load->view('layout/header', $data);
    $this->load->view('layout/menu', $data);
    $this->load->view('add', $data);
    $this->load->view('script/add_script', $data);
    $this->load->view('layout/footer', $data);
}

function select_proker(){
    if('IS_AJAX') {
    $data['option_proker'] = $this->MChain->getProkerList();        
        $this->load->view('dropdown',$data);
    }

}

function select_kegiatan(){
    if('IS_AJAX') {
    $data['option_kegiatan'] = $this->MChain->getKegiatanList();        
        $this->load->view('dropdownn',$data);
    }

}

模型

<form class="form-horizontal" id="validation-form" method="get">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="platform">Bidang</label>
        <div class="col-xs-12 col-sm-9">
            <div class="clearfix">
                <?php
                    echo form_dropdown("bidang_id",$option_bidang,"","id='bidang_id'");
                ?>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="platform">Program Kerja</label>
        <div class="col-xs-12 col-sm-9">
            <div class="clearfix">
                <div id="proker">
                    <?php
                        echo form_dropdown("proker_id",array('Pilih Program Kerja'=>'Pilih Bidang Dahulu'),'','disabled');
                    ?>
                </div>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="platform">Kegiatan</label>
        <div class="col-xs-12 col-sm-9">
            <div class="clearfix">
                <div id="kegiatan">
                    <?php
                        echo form_dropdown("kegiatan_id",array('Pilih Kegiatan'=>'Pilih Program Kerja Dahulu'),'','disabled');
                    ?>
                </div>
            </div>
        </div>
    </div>

    <div class="space-2"></div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="tgl">Tanggal Pelaksanaan Program Kerja</label>

        <div class="col-xs-12 col-sm-3">
            <div class="clearfix">
                <div class="input-group">
                    <input class="form-control date-picker" name="tgl" id="tgl" type="text" data-date-format="dd-mm-yyyy" />
                    <span class="input-group-addon">
                        <i class="fa fa-calendar bigger-110"></i>
                    </span>
                </div>
            </div>
        </div>
    </div>

    <div class="space-8"></div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-3 no-padding-right" for="comment">Keterangan Program</label>

        <div class="col-xs-12 col-sm-9">
            <div class="clearfix">
                <textarea class="input-xlarge" name="comment" id="comment"></textarea>
            </div>
        </div>
    </div>
</form>

另一个下拉菜单视图
1. dropdown.php

function getBidangList(){
        $result = array();
        $this->db->select('*');
        $this->db->from('master_bidang');
        $this->db->order_by('var_bidang','ASC');
        $array_keys_values = $this->db->get();
        foreach ($array_keys_values->result() as $row)
        {
            $result[0]= '-Pilih Bidang-';
            $result[$row->int_idbidang]= $row->var_bidang;
        }

        return $result;
    }

    function getProkerList(){
        $bidang_id = $this->input->post('bidang_id');
        $result = array();
        $this->db->select('*');
        $this->db->from('master_proker');
        $this->db->where('int_idbidang',$bidang_id);
        $this->db->order_by('var_proker','ASC');
        $array_keys_values = $this->db->get();
        foreach ($array_keys_values->result() as $row)
        {
            $result[0]= '-Pilih Program Kerja-';
            $result[$row->int_idproker]= $row->var_proker;
        }

        return $result;
    }

    function getKegiatanList(){
        $proker_id = $this->input->post('proker_id');
        $result = array();
        $this->db->select('*');
        $this->db->from('master_kegiatan');
        $this->db->where('int_idproker',$proker_id);
        $this->db->order_by('var_kegiatan','ASC');
        $array_keys_values = $this->db->get();
        foreach ($array_keys_values->result() as $row)
        {
            $result[0]= '-Pilih Kegiatan-';
            $result[$row->int_idkegiatan]= $row->var_kegiatan;
        }

        return $result;
    }


2。 dropdownn.php

<?php
        echo form_dropdown("proker_id",$option_proker,'',"id='proker_id'");
    ?>


请帮我:(

0 个答案:

没有答案