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

WBOY
Release: 2016-06-02 11:31:57
Original
969 people have browsed it

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>
Copy after login

这是 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>
Copy after login

大神帮忙看看 怎么回事!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template