I’m trying to find a specific solution for cakePHP but I got bullied instead of getting a good answer.
After a lot of searching I’ve found this great blog post which exactly solve my problem.
http://blog.jandorsman.com/2011/01/using-ajax-and-cakephp-to-dynamically-populate-select-form-fields/
If you’re using a newer version of CakePHP. you need to use different functions JS helper instead
$this->Js->get('#BookId')->event(
'change',
$this->Js->request(
array('controller'=>'Books','action'=>'your_ajax_function'),
array('update' => '#BooksAuthorId', 'dataExpression' => true, 'data' => '$("#BookId").serialize()')
)
);
The above code won’t generate the javaScript code. It will just cache it. you need to execute this function at the end of your view file to generate the code.
<?php echo $this->Js->writeBuffer(); ?>
solved how to create form with a drop-down list that change the other option depend on selection [duplicate]