Yii Framework Forum: Isi Fieldtext Otomatis Dari Hasil Hitung Dropdownlist - Yii Framework Forum

Jump to content

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

Isi Fieldtext Otomatis Dari Hasil Hitung Dropdownlist Cactiveform Rate Topic: -----

#1 User is offline   Devanlustig 

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

Posted 12 January 2014 - 11:08 AM

saya coba mengisi fieldtext otomatis dari hasil hitung dropdownlist pada form

code saya kaya gini

<?php $s=$model->Harga; ?>

<?
echo"<script type='text/javascript'>
function addText()
{
var x = document.getElementById('pemesanan_Ukuran');
var y = document.getElementById('pemesanan_Harga');
y.value = x.value*'$s';
}
</script>";
?>

<div class="row">
<?php echo $form->labelEx($model2,'Ukuran'); ?>
<?php echo $form->DropdownList($model2,'Ukuran',array(
'1'=>'2m x 2m',
'1.2'=>'2m x 3m',
'2.3'=>'Lainnya'),
array('onchange'=>'javascript: addText();' ,'prompt'=>'--pilih--'));
?>
<div class="row">
<?php echo $form->labelEx($model2,'Harga'); ?>
<?php echo $form->textField($model2,'Harga',array('style'=>'width:75px;','size'=>25, 'maxlength'=>25,'value'=> $model->Harga, 'readonly'=>'readonly')); ?>
</div>

jadi harapan saya yg tersimpan itu ukurannya '2m x 2m' bukan angka 1 Mohon Bantuannya
0

#2 User is offline   Abu Fathir 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 14-April 12

Posted 31 January 2014 - 07:08 AM

Ini masalah javascript kali ya, bukan yii
Untuk ambil nilai dropdown kira-kira begini
<script type='text/javascript'>
var y = document.getElementById('pemesanan_Harga');

var nilai = y.options[y.selectedIndex].text;
</script>"



variabel nilai sudah berisi "2m x 2m" jika yang dipilih val=1
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