Welcome Guest, Not a member yet? Register   Sign In
dynamic form_dropdown
#1

Hello,

how to make a dynamic form_dropdown?
I have this in my view:
Code:
<tr>
<td align="right" scope="row">Project Name</td>
<td>
<?php

$project_id = set_value('project_id', @$user[0]->DFLT_PROJECT_ID);

echo form_dropdown('project_id"'.' class="form-control', $projectlist, $project_id);

            ?>
<span class="text-danger"><?php echo form_error('project_id'); ?></span>
</td>
</tr>
<tr>
<td align="right" scope="row">Stream Name</td>
<td>
<?php

$stream_id = set_value('stream_id', @$user[0]->DFLT_STREAM_ID);

echo form_dropdown('stream_id"'.' class="form-control', $streamlist, $stream_id);

            ?>
<span class="text-danger"><?php echo form_error('stream_id'); ?></span>
</td>
</tr>
 
I want the stream to be dependent on what the project_id will be. 

This is my controller 
Code:
    public function add_form_show($view) {
        $data['jira_hard_block'] = $this->settings_model->get_settings_by_type('JIRA_HARD_BLOCK');

        $session_user = get_cookie('auditme_cookie');
        $id = $this->user_model->get_id_by_user_name($session_user);
        $data['user'] = $this->user_model->get_user_by_id($id);
        $projectresult = $this->project_model->get_project_dropdown_list();
        $data['projectlist'] = $projectresult;
   $project_id = 1;
        $streamresult = $this->stream_model->get_stream_dropdown_list($project_id);
        $data['streamlist'] = $streamresult;

        $this->load->view($view, $data);
    }

And this is my model:

Code:
    function get_stream_dropdown_list($project_id = '') {
    if ($project_id <> ''){
      $this->db->where("proj_id",$project_id);
      }
$this->db->order_by('STREAM_CODE', 'ASC');
$query = $this->db->get('AUDIT_STREAM');


        $result = $query->result();
if ($query->num_rows()>0) {
$data[''] = '- Please Select -';
            foreach($query->result() as $row) {
                $data[$row->ID] = $row->STREAM_NAME;
            }
            return $data;
        }
        return $result;
    }

Help please.
Reply


Messages In This Thread
dynamic form_dropdown - by jennyvin16 - 03-15-2019, 02:02 AM
RE: dynamic form_dropdown - by php_rocs - 03-15-2019, 09:04 AM
RE: dynamic form_dropdown - by jennyvin16 - 03-17-2019, 06:39 PM
RE: dynamic form_dropdown - by ciadmin - 03-17-2019, 08:22 PM
RE: dynamic form_dropdown - by includebeer - 03-19-2019, 11:09 AM
RE: dynamic form_dropdown - by jennyvin16 - 03-21-2019, 10:13 PM
RE: dynamic form_dropdown - by includebeer - 03-28-2019, 05:27 AM
RE: dynamic form_dropdown - by includebeer - 03-27-2019, 04:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB