0

I have managed to get the ajax function in cakephp which calls when a dropdown is clicked to populate another dropdown. The one area I cannot get is passing in the id value of the first dropdown so I can do a find.

I wish to pass in the company id so I can get the related employees.

Thanks.

View:

<?php
$this->Js->get('#MonthlyReturnCompanyId')->event('change',
$this->Js->request(
    array(
        'controller'=>'MonthlyReturns',
        'action'=>'getemployees',
    ),
    array(
        'update'=>'#test',
        'async' => true,
        'method' => 'post',
        'dataExpression'=>true,
        'data'=> $this->Js->serializeForm(array(
            'isForm' => false,
            'inline' => true
        ))
    )
)
);
?>



        echo $this->Form->input('company_id' , array('empty' => true));
Keith Power
  • 13,891
  • 22
  • 66
  • 135

1 Answers1

0

simply pass the company_id at the action request same as done in redirects i.e. :

 $this->Js->request(
array(
    'controller'=>'MonthlyReturns',
    'action'=>'getemployees',$company_id),
array(
    'update'=>'#test',
    'async' => true,
    'method' => 'post',
    'dataExpression'=>true,
    'data'=> $this->Js->serializeForm(array(
        'isForm' => false,
        'inline' => true
    ))
)
)
);
Diablo Geto
  • 457
  • 4
  • 21