Fill Text Field Based On Drop Down List Select

I have a dropdown List and Two TextField.

I want to fill the text field based on Dropdown List selected.

This is my code :

  • _form

<div class="row">

		<?php echo $form->labelEx($model,'id_barang_pakai'); ?>

		<!--<?php echo $form->textField($model,'id_barang_pakai'); ?>!-->

		<?php echo $form->dropDownList($model,'id_barang_pakai', CHtml::listData(barang::model()->findAll(array('order' => 'id_barang')),'id_barang','nama_barang'));?>

                <?php echo $form->error($model,'id_barang_pakai'); ?>


<div class="row">

		<?php echo $form->labelEx($model,'status'); ?>

		<!--<?php echo $form->textField($model,'status',array('size'=>60,'maxlength'=>80)); ?>!-->

		<?php echo $form->textField($model,'status',CHtml::listData(barang::model()->findAll(array('order' => 'id_barang')),'id_barang','status'));?>

		<?php echo $form->error($model,'status'); ?>


<div class="row">

		<?php echo $form->labelEx($model,'kondisi'); ?>

		<?php echo $form->textField($model,'kondisi',array('size'=>60,'maxlength'=>80)); ?>

		<?php echo $form->error($model,'kondisi'); ?>



public function actionCreate()


		$model=new serah;

		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);











I get the Data from One table,

If I choose one item from dropdown List,

I want two text field values according to the dropdown list selected.

The text field will show the description of the item in drop down list.

Thank you



How ?

Post your solution, so that when some body search it in google then he finds the solution.


This is the detail of my solution