Hi,
I’m testing ajax features and I’m having a problem getting a dependant dropdownlist to work.
This is my form page :
<div class="row">
<?php echo $form->labelEx($model,'langId'); ?>
<?php
echo $form->dropDownList($model,'langId',array('1'=>'English', '2'=>'Bangla'),array(
'id'=>'langId',
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('birthRegDtl/dynamiclang'),
'update'=>'#'.CHtml::activeId($model,'prCountryId')
),
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('birthRegDtl/dynamiclangR'),
'update'=>'#'.CHtml::activeId($model,'religionId')
)
));
?>
<?php echo $form->error($model,'langId'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'religionId'); ?>
<?php echo $form->dropDownList($model,'religionId',array()); ?>
<?php echo $form->error($model,'religionId'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'prCountryId'); ?>
<?php
echo $form->dropDownList($model,'prCountryId',array());
?>
<?php echo $form->error($model,'prCountryId'); ?>
</div>
here is my controller page…
public function actionDynamiclang() {
$data=MstCountry::model()->findAll('lang=:lang',
array(':lang'=>(int) $_POST['BirthRegDtl']['langId']));
echo CHtml::tag('option',
array('value'=>''),'Please select a country.',true);
$data=CHtml::listData($data,'countryId','name');
foreach($data as $value=>$country)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($country),true);
}
}
public function actionDynamiclangR() {
$data=MstReligion::model()->findAll('lang=:lang',
array(':lang'=>(int) $_POST['BirthRegDtl']['langId']));
echo CHtml::tag('option',
array('value'=>''),'Please select a Religion.',true);
$data=CHtml::listData($data,'religionId','name');
foreach($data as $value=>$religion)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($religion),true);
}
}
I want to change the value of Country ang religion field if change lanuage filed
what can I do for this. please any one help me…