wi_bert
(Wilbertkaluasa)
September 26, 2012, 9:10am
1
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
Keith
(Kburton)
September 26, 2012, 10:08am
2
If you’re using jQuery, you could do something like
$('#dropdownId').change(function(){
$('#textfieldId').val($(this).find(':selected').text());
});
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.
wi_bert
(Wilbertkaluasa)
September 27, 2012, 1:56am
3
Keith:
If you’re using jQuery, you could do something like
$('#dropdownId').change(function(){
$('#textfieldId').val($(this).find(':selected').text());
});
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
karasawaz
(Blitzray1986)
September 27, 2012, 2:46am
4
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,
http://www.yiiframework.com/forum/index.php/topic/18517-ajax-update-a-textfield-based-on-a-dropdownlist-value/
wi_bert
(Wilbertkaluasa)
September 27, 2012, 3:10am
5
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>
<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)); ?>
</div>
i use that, because facilitate users to search data… could you help me thanksss
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>
<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)); ?>
</div>
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?