This is the code view: & quot; & #39; 1 & #39;, 2 & gt; & #39; 2 & #39;), array (& #39; empty & #39; & gt; & #39; -- select -- & #39;, & #39; id & #39; & gt; & #39; node & #39;, & #39; ajax & #39; & gt; array (& #39; type & #39; & gt; & #39; POST & #39;, & #39; url & #39; & gt; Yii: app ()-& gt; createUrl (& #39; testupdatea & #3 ajaxphpyii selection Association
This is the code
View:
'1', 2 => '2'), array ('empty' => '-- select --', 'id' => 'node ', 'Ajax '=> array ('type' => 'post', 'URL' => Yii: app ()-> createUrl ('test/updatea '), 'update' => '# servers', 'data' => array ('node _ name' => 'JS: $ ("# node "). val () '),); echo CHtml: dropDownList ('servers', '', array (' -- select -- ');?>
This is controller
Class TestController extends Controller {public function actionIndex () {$ this-> renderPartial ('index');} public function actionUpdatea () {$ data = array (1 => 'guilin ', 2 => 'nanning'); foreach ($ data as $ value => $ name) {$ dropDownCities = CHtml :: tag ('option', array ('value' => $ value), CHtml: encode ($ name), true);} echo $ dropDownCities ;}}
Let's take a look at what's going on!