I'm a complete CakePHP and AJAX newbie. I'm trying to set up a pretty
simple ajax select element where my selecting an option in select A
will display relevant choices in a new select B. For whatever reason,
the code I've implemented is not working. My guess is that I'm missing
something vital in the ajax action, but I've tried everything I can
think of with no results.

Here is what I have:

******************************ajax action controller:
        function users_from_company()
        {
                $this->layout = 'ajax';
                $users = $this->User->findAll(array('company_id' =>
$this->data['company']));
                $optionElements = array();
                foreach ($users as $user)
                {
                        $optionElements[$user['User']['id']] = 
$user['User']['username'];
                }
                $this->set('optionElements', $optionElements);
        }

******************************view:
        <p>
                Company:
                <?php
                $companyselect = array();
                foreach ($companies as $company)
                {
                        $companyselect[$company['Company']['id']] =
$company['Company']['company_name'];
                }
                echo $html->selectTag('Video/company_id', $companyselect, null,
array('id' => 'company'));
                ?>
        </p>
        <p>
                <div id="usersFromCompany"></div>
        </p>
        <?php
        echo $ajax->observeField('company', array('frequency'=>1,
'url'=>'/videos/users_from_company/', 'update'=>'usersFromCompany',
'with'=>'company'));
        ?>

************************************ajax output view:
<?php $html->selectTag('Video/user_id', $optionElements); ?>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to