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>
<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>
<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'); ?>
</div>
-actionCreate
public function actionCreate()
{
$model=new serah;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['serah']))
{
$model->attributes=$_POST['serah'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$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