samubra 2012-01-17 11:15:01 3822次浏览 2条回复 0 0 0

我一直都是用dropDownList的ajax来实现下拉菜单的,目前我有三个:

<?php
echo $form->dropDownListRow ( $model, 'subject_id', Subject::SubjectOptions (), array ('class' => 'span8',
'ajax' => array (
    'type' => 'POST', //request type
    'url' => $this->createUrl ( 'ajaxunitlist' ), //url to call
    'update' => '#Exam_unit_id' 
), //selector to update
'options' => array (isset ( $_GET ['subject_id'] ) ? $_GET ['subject_id'] : '' => array ('selected' => true ) ) ) );
?>
<?php 
echo $form->dropDownListRow($model, 'unit_id', Unit::UnitOptions(), array('class' => 'span8',
    'ajax' => array (
        'type' => 'POST', //request type
        'url' => $this->createUrl ( 'ajaxchapterlist' ), //url to call
        'update' => '#Exam_chapter_id' 
    ), //selector to update
    'options' => array (isset ( $_GET ['unit_id'] ) ? $_GET ['unit_id'] : '' => array ('selected' => true ) ) ));
?>
<?php 
echo $form->dropDownListRow($model,'chapter_id',Chapter::ChapterOptions(),array('class'=>'span8','id'=>'Exam_chapter_id','options' => array (isset ( $_GET ['chapter_id'] ) ? $_GET ['chapter_id'] : '' => array ('selected' => true ) )));
?>

它已经能正常工作了,但我现在想要它更先进一点,就是在改变第一个dropdown(subject)的时候,同时更新第二个和第三个,但第二个和第三个内容不同,可否有什么办法? 我尝试着在update里面加一个id,同时更新了,但二三两个更新的内容一样:

<?php
echo $form->dropDownListRow ( $model, 'subject_id', Subject::SubjectOptions (), array ('class' => 'span8',
    'ajax' => array (
        'type' => 'POST', //request type
        'url' => $this->createUrl ( 'ajaxunitlist' ), //url to call
        'update' => '#Exam_unit_id,#Exam_chapter_id' 
    ), //selector to update
    'options' => array (isset ( $_GET ['subject_id'] ) ? $_GET ['subject_id'] : '' => array ('selected' => true ) ) ) );
?>
您需要登录后才可以回复。登录 | 立即注册