Part of the EllisLab Network
   
 
[Solved] xajax + CI help please
Posted: 14 November 2007 08:54 PM   [ Ignore ]  
Grad Student
Rank
Total Posts:  89
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 03:41 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  89
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() > 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;
}
 Signature 

ATOMIC Web Hosting - Quality Shared & Reseller Web Hosting

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 10:15 AM
Total Registered Members: 119744 Total Logged-in Users: 30
Total Topics: 125923 Total Anonymous Users: 2
Total Replies: 662538 Total Guests: 404
Total Posts: 788461    
Members ( View Memberlist )