How To Show Data To Textfield Based On Dropdownlist

hi there… i’m newbie…

i have a problem, i want show data to a textfield based on dropdown value

i have data barang where

kodebarang => dropdown

namabarang => textfield

if i choose data from dropdown so textfield will be fill data from namabarang ??

could you solving my problem ???

If you’re using jQuery, you could do something like




That’s assuming you want the text of the selected dropdown item, not the value, and that you’ve assigned an ID to both the select box and the text field.

ogh thanks before for your help…

but I want is take the value of namabarang from the database based kodebarang and show it to textfield,

maybe you have advice or a reference ???

can you show me the dropdown code that you make?

And if i may ask, what is the purpose of passing the dropdown value to textfield?

Nb: maybe this method will help,

i have code like this :

<div class="row">

        <?php echo $form->label($model, 'KodeBarang'); ?>

        <?php echo $form->dropDownList($model, 'KodeBarang', CHtml::listData(Barang::model()->findAll(array

        ('group' => 'KodeBarang')), 'KodeBarang', 'KodeBarang'), array('empty' => 'Select Kode Barang')) ?>


    <div class="row">

         <!-- if choose value from dropdown, so textfield will show data -->

        <?php echo $form->label($model, 'NamaBarang'); ?>

        <?php echo $form->textField($model, 'NamaBarang', array('size' => 50, 'maxlength' => 50)); ?>


i use that, because facilitate users to search data… could you help me ??? thanksss

I Have same problem with this. How to solve this problem?