关于联动下拉菜单 [ 新手入门 ]
我一直都是用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 ) ) ) );
?>
共 2 条回复
samubra
注册时间:2011-07-28
最后登录:2014-04-09
在线时长:0小时0分
最后登录:2014-04-09
在线时长:0小时0分
- 粉丝1
- 金钱1200
- 威望0
- 积分1200