Home  >  Article  >  Backend Development  >  ajax- 最近想弄一个 Yii 的下拉框级连操,但是一直出不来,大神帮忙看看吧!!!

ajax- 最近想弄一个 Yii 的下拉框级连操,但是一直出不来,大神帮忙看看吧!!!

WBOY
WBOYOriginal
2016-06-02 11:31:57941browse

ajaxphpyii选择联动

这是代码
view:

<code>  <?phpecho CHtml::dropDownList('node', '',array(1=>'1',2=>'2'),array('empty'=>'--请选择--',        '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('--请选择--'));?></code>

这是 controller

<code>  class TestController extends Controller{    public function actionIndex(){          $this->renderPartial('index');}    public function actionUpdatea(){      $data = array(1=>'桂林',2=>'南宁');    foreach($data as $value=>$name){     $dropDownCities = CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);    }  echo  $dropDownCities ;}}</code>

大神帮忙看看 怎么回事!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn