PHP完全自学手册(珍藏版) 中文pdf扫描版下载
labelEx($model,'clientid'); ?>
textField($model,'projectid'); ?>
dropDownList($model,'clientid', CHtml::listData(Client::model()->findAll(), 'code','name'),
array(
'prompt' => '--Please Select --',
'value' => '0',
'ajax' => array(
'type' => 'POST',
'url' => CController::createUrl('task/projects'),
'update' => '#Task_projectid', //selector to update value
'data' => array('clientid'=>'js:this.value'),
)
)
); ?>
labelEx($model,'projectid'); ?>
dropDownList($model,'projectid', array('empty'=>'--please select--')); ?>
error($model,'projectid'); ?>
The controller action
public function actionProjects(){
$giatUnit = (!empty($_POST['clientid'])) ? $_POST['clientid']: '0';
$data=Project::model()->findAll('clientid=:clientid',
array(':clientid'=>$giatUnit));
$data=CHtml::listData($data,'id','name');
foreach($data as $value=>$name)
{
echo CHtml::tag('option',array('value'=>$value),CHtml::encode($name),true);
}
}
转载请注明:谷谷点程序 » Yii dropDownList onChange