Yii Framework Forum: Cara Isi Fieldtext Otomatis Dari Hasil Perkalian - Yii Framework Forum

Jump to content

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

Cara Isi Fieldtext Otomatis Dari Hasil Perkalian Rate Topic: -----

#1 User is offline   Devanlustig 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-November 12

Posted 14 January 2014 - 07:17 AM

saya punya 3 fieldtext yaitu Jumlah , Harga , dan Total bagaimana cara mengisi total dari hasil perkalian input di Jumlah dan Harga
Saya ud nyoba pke javascript n code nya kaya gini tp msi blm nemu

<? 
 echo"<script type='text/javascript'>
 function addText() 
 {
 var x = document.getElementById('Jumlah.value');
 var y = document.getElementById('Harga.value');
 document.getElementById.Total.value = (x*y);
}
 </script>";
?>

<div class="form">
<div class="row">
<?php echo $form->textField($model,'Jumlah',array('size'=>25,'maxlength'=>25),
			array('onfocus'=>'javascript: addText();')); ?>
</div>
<div class="row">
<?php echo $form->textField($model,'Harga',array('size'=>25,'maxlength'=>25),
		array('onfocus'=>'javascript: addText();')); ?>
</div>
<div class="row">
<?php echo $form->textField($model,'Total',array('size'=>25,'maxlength'=>25,'value'=> $model->Total,'readonly'=>'readonly'),
		array('onfocus'=>'javascript: addText();')); ?>
</div>


mohon bantuannya
0

#2 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 329
  • Joined: 10-November 10

Posted 15 January 2014 - 07:13 AM

Gan, ini total perkaliannya itu terisi otomatis waktu kapan? Apakah waktu user pindah kursor dari textfield? Ato waktu inputnya diketik?

Kalo ane boleh saranin (sekedar saran aja nih, ya :) ) mendingan pake jQuery. Trus juga perlu dicek apakah ID dari textfield-nya itu memang benar 'Jumlah.value' and 'Harga.value' ato bukan (bisa pake fasilitas View Source ato Inspect Element di web browser yang bersangkutan).

This post has been edited by rei: 15 January 2014 - 07:22 AM

Fipick - Find and pick recommendations
0

#3 User is offline   Devanlustig 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-November 12

Posted 15 January 2014 - 11:25 PM

View Postrei, on 15 January 2014 - 07:13 AM, said:

Gan, ini total perkaliannya itu terisi otomatis waktu kapan? Apakah waktu user pindah kursor dari textfield? Ato waktu inputnya diketik?

Kalo ane boleh saranin (sekedar saran aja nih, ya :) ) mendingan pake jQuery. Trus juga perlu dicek apakah ID dari textfield-nya itu memang benar 'Jumlah.value' and 'Harga.value' ato bukan (bisa pake fasilitas View Source ato Inspect Element di web browser yang bersangkutan).


pas pindah textfield gan.....
ada referensi contoh nya g gan??? saya blm prnah pke jQuery di Yii hehehehe
0

#4 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 329
  • Joined: 10-November 10

Posted 16 January 2014 - 08:43 PM

View PostDevanlustig, on 15 January 2014 - 11:25 PM, said:

pas pindah textfield gan.....
ada referensi contoh nya g gan??? saya blm prnah pke jQuery di Yii hehehehe


Mendingan cari2 dulu aja, gan. Contohnya seperti yang di sini.
Fipick - Find and pick recommendations
0

#5 User is offline   tiltleft 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 01-January 14

Posted 17 January 2014 - 03:08 AM

Itu bener id textfieldnya Jumlah?
<?php echo $form->textField($model,'Jumlah',array('size'=>25,'maxlength'=>25),
                        array('onfocus'=>'javascript: addText();')); ?>

Coba di inspect element
0

#6 User is offline   Devanlustig 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 02-November 12

Posted 23 January 2014 - 05:41 AM

View Posttiltleft, on 17 January 2014 - 03:08 AM, said:

Itu bener id textfieldnya Jumlah?
<?php echo $form->textField($model,'Jumlah',array('size'=>25,'maxlength'=>25),
                        array('onfocus'=>'javascript: addText();')); ?>

Coba di inspect element


id textfieldnya pembelian_bahan_Jumlah....
saya ud rubah javascriptnya jd

<?
echo"<script type='text/javascript'>
function addText()
{
var x = document.getElementById('pembelian_bahan_Jumlah');
var y = document.getElementById('pembelian_bahan_Harga');
var z = document.getElementById('pembelian_bahan_Total');
document.getElementById.pembelian_bahan_Total = (x*y);

}
</script>";
tp te2p ga fungsi
0

#7 User is offline   deny 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 25-February 14

Posted 27 February 2014 - 09:36 AM

gan kalo kaya gini kasusnya gimana ya
gan cara nya gimana ya buat nampilin otomatis field jumlah_waktu setelah jam_awal dan akhir_terisi. mohon bantuan banget. makasi
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