Part of the EllisLab Network
   
 
[Solved] xajax + CI help please
Posted: 14 November 2007 10:54 PM   [ Ignore ]  
Lab Assistant
RankRank
Total Posts:  106
Joined  08-21-2007

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

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
 Signature 

ATOMIC Web Hosting - Quality Shared & Reseller Web Hosting

Profile
 
 
Posted: 15 November 2007 05:41 PM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  106
Joined  08-21-2007

It’s ok - I solved it.

Solved function.

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() > {
        $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
 Signature 

ATOMIC Web Hosting - Quality Shared & Reseller Web Hosting

Profile