Welcome Guest, Not a member yet? Register   Sign In
[Solved] xajax + CI help please
#1

[eluser]LifeSteala[/eluser]
I have this function in my controller, and I have the <select> in the view. Well 2 selects, one client and one project. The controller passes the client result to the view and in the view it loops out the clients.

On client select i can get the ClientID using ajax, but I cant populate the 2nd select, projects..

Can anyone help me? Cheers

Code:
function get_projects($clientID)
{
    $proj_query = $this->projects->getProjectsA($clientID);
    $objResponse = new xajaxResponse();
    foreach($proj_query as $rows)
    $options = "<option value='{$rows->project_id}'>{$rows->project_name}</option>\n";
        
    $objResponse->Assign("change","innerHTML", $options);
    return $objResponse;
}
#2

[eluser]LifeSteala[/eluser]
It's ok - I solved it.

Solved function.

Code:
function get_projects($clientID)
{
    $proj_query = $this->projects->getProjectsA($clientID);
    
    $output = '<label for="project">Project: </label>';
    $output .= '<select name="project">\n';
    
    if ( $proj_query->num_rows() > 0 ) {
        $output .= '<option selected="selected"></option>';
        
        foreach($proj_query->result() as $rows)
            $output .= "<option value=\"{$rows->project_id}\">{$rows->project_name}</option>";
    }
    else
        $output .= '<option selected="selected"></option>';
    
    $output .= '</select>';
    
    $objResponse = new xajaxResponse();
    $objResponse->Assign("optionProjects","innerHTML", $output);
    return $objResponse;
}




Theme © iAndrew 2016 - Forum software by © MyBB