Yii Framework Forum: perkalian antar textfield dan hasil tampilkan otomatis - Yii Framework Forum

Jump to content

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

perkalian antar textfield dan hasil tampilkan otomatis perkalian antar textfield _form.php Rate Topic: -----

#1 User is offline   jurunkid 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 29-October 14

Posted 07 January 2015 - 03:46 AM

ada yang tau agan2???
itu di _form.php,..lihat foto :
Attached File  form.jpg (34.88K)
Number of downloads: 22


thanks :)
0

#2 User is offline   dika46 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 26-February 13
  • Location:Indonesia

Posted 20 January 2015 - 04:53 AM

Case ini bisa ditempuh dengan memanfaatkan jQuery:


Yii::app()->clientScript->registerScript('hitungTotal', "
	function hitungTotalBarang() {
		var hargaBarang = $('#NamaModel_hargaBarang').val();
		var qtyBarang = $('#NamaModel_qtyBarang').val();
		var totalHarga;

		totalHarga = parseInt(hargaBarang) * parseInt(qtyBarang);

		$('#NamaModel_totalHarga').val(totalHarga);
	}

	$('#NamaModel_hargaBarang').live('change', function() { hitungTotalBarang(); });
	$('#NamaModel_qtyBarang').live('change', function() { hitungTotalBarang(); });
");

$form->textField($model, 'hargaBarang');
$form->textField($model, 'qtyBarang');
$form->textField($model, 'totalHarga');




berlaku di Yii1

regards,
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