I’m running into some trouble here. I have a form and I need to change the content of some view elements (e.g. drop down lists) automatically, when the content of one drop down list changes. So I thought about calling two or more functions via ajax. Is it possible and if yes: how can it be done?
Any help, tips, etc. are highly appreciated.
Thanks in advance,
You can do like that:
Create a div (#toreplace in my example) in wich to put all stuffs that have to be ajax-replaced.
You can create your dropdownlist like that:
<?php echo CHtml::activeDropDownList(
thanks for the quick reply.
Do you have a short example on how to fill the div? I don’t get the point at the moment…
Thanks a lot,
First of all, be informed that you are going in one of the most complex and still not completely debugged part of the framework (I mean, clientScript, ajax and so on is not as stabe as you can hope).
You can do something like:
Create a subview like that:
<?php CHtml::activeDropDownList($model, 'attribute1', CHtml::list([...], array('onChange'=>ajax([...]))))?>
<?php CHtml::activeDropDownList($model, 'attribute2', CHtml::list([...], array('onChange'=>ajax([...]))))?>
<?php CHtml::activeDropDownList($model, 'attribute3', CHtml::list([...], array('onChange'=>ajax([...]))))?>
In the controller, create an action ajax like that:
public function actionAjax()
// do what you have to do
The change on the dropDownList will lauch an ajaxRequest to the actionAjax, that will return the subview. This subview will be replaced in your page.
If you still have problem, try posting again!