Yii Framework Forum: Bagaimaa Caranya Mengisi Beberapa Textbox saat pilih Dropdown - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Bagaimaa Caranya Mengisi Beberapa Textbox saat pilih Dropdown Rate Topic: -----

#1 User is offline   i_kurnia 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 13-March 18

Posted 13 March 2018 - 11:27 PM

Halo agan2 semua,

Saya Newbie di php Yii2, Sekarang saya lagi buat aplikasi Inventory menggunakan Yii2framworks,
cuma saat ini saya stack ada kendala. Yang saya maksud seperti berikut.

1. Saya buat sebuah Dropdown dari data tabel A (kode barang, nama barang) misalkan ditampilkan nama Barang.
2. Saat Dropdown itu dipilih datanya akan mengambil data di tabel B (isinya kode barang, lokasi dan jumlah) berdasarkan kode barang yang dipilih di Dropdown tsb,
3. Data yang diambil akan disimpan di 2 textbox, txtLokasi dan txtQuantity,

Pertanyaannya, bagaimana cara untuk membuat script langkah 2 dan 3.

Saya harap bantuan agan2 semua, Urgent pls.

Terima Kasih,

Iwan K





Ini contoh View nya

<div class="budgets-form">
<div class="container-fluid">
<?php
$form = ActiveForm::begin([
'id' => 'new-form',
'options' => ['class' => 'form-horizontal'],
'method' => 'post',
]);
?>
<div>
<div class="form-group">
<label class="control-label col-sm-2" for="fld_no">No. Circulait :</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fld_no" name="fld_no" readonly value=" <?php echo $no ?> ">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fld_pos">Posisi Baris :</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fld_pos" placeholder="Posisi Baris" readonly name="fld_pos" value=" <?php echo $pos ?> ">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fld_budget">Budget :</label>
<div class="col-sm-10">
<?php
echo Html::dropDownList('fld_budget', null, ArrayHelper::map(app\models\BudgetDetail::find()
->where('fld_status' . " = 'Active'")
->all(), 'fld_no', 'fld_deskripsi'), [
'prompt' => Yii::t('app', 'Pilih Budget...'),
'onChange' => '$.post( "' . Yii::$app->urlManager->createUrl(["/circulait/getbdgt", 'id' => '']) . '",function(data){$("#fld_bpos").val(data);})',
'id' => 'fld_budget',
'class' => 'dependent-input form-control',
'ajax' => [
'type' => 'POST',
'url' => Yii::$app->urlManager->createUrl(['/circulait/getbdgt', 'id' => Yii::$app->request->post()]),
'update' => '#fld_bpos',
'data' => ['fld_budget' => 'js:this.value'],
'success' => 'alert ("ok");'
]
]);
?>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fld_bpos">Budget Line No. :</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fld_bpos" placeholder="Budget Line No" name="fld_bpos">
</div>
</div>

<div class="form-group">
<label class="control-label col-sm-2" for="fld_jenis">Jenis Budget :</label>
<div class="col-sm-10">
<?php
echo Html::dropDownList('fld_jenis', null, ArrayHelper::map($tStatus, 'id', 'name'), [
'prompt' => Yii::t('app', 'Pilih Jenis...'),
'id' => 'fld_jenis',
'class' => 'dependent-input form-control',
]);
?>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fld_deskripsi">Rincian :</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fld_deskripsi" placeholder="Rincian" name="fld_deskripsi" >
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fld_ket">Keterangan :</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fld_ket" placeholder="Keterangan" name="fld_ket">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fld_curr">Currency :</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fld_curr" placeholder="Mata Uang" name="fld_curr" value="IDR">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="fld_amount">Amount :</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="fld_amount" placeholder="Jumlah" name="fld_amount" value="0">
</div>
</div>
<div class="col-sm-12 form-group">
<?=
Html::submitButton('Simpan', [
'content' => 'Button',
// 'value' => Url::to(['trsmaster/simpan']),
'value' => 'ok',
'class' => 'btn btn-success',
'id' => 'create-btn',
'name' => 'submitbtn'
])
?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
0

#2 User is offline   i_kurnia 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 13-March 18

Posted 19 March 2018 - 01:27 AM

Help me pls....!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users