Sorry, I dont know yii in javascript.
Im make dropdownlist where value get for dynamic show and hidden form-field. Any clue…?
My View
<?php $cs = Yii::app()->getClientScript();
$cs->registerScript('seleccion',
'function seleccion(obj){
if(obj=="1"){
document.getElementById("attend").style.display="block";
document.getElementById("un-attend").style.display="none";
return false;
}
if(obj=="15"){
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="block";
return false;
}
if(obj=="16"){
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="block";
return false;
}
if(obj=="17"){
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="block";
return false;
}
if(obj=="18"){
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="block";
return false;
}
if(obj=="23"){
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="block";
return false;
}
if(obj=="24"){
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="block";
return false;
}
if(obj=="25"){
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="block";
return false;
}
if(obj=="26"){
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="block";
return false;
}
else{
document.getElementById("attend").style.display="none";
document.getElementById("un-attend").style.display="none";
return false;
}
}
',
CClientScript::POS_END
);
?>
<?php echo $form->dropDownListRow($model, 'id_status', CHtml::listData(Status::model()->findAll(array('condition'=>"t.set_trx_kemunculan = 2")), 'id', 'fullName'), array(
'prompt'=>'Pilih Status','onchange'=>'return seleccion(this.value)')); ?>
And my div Attend and un-attend is
<div id="attend" class="row" style="display:none"><?php echo $form->datepickerRow($model, 'tgl_selesai', array(
'class' => 'span20 input-inline',
'options' => array(
'format' => 'dd-mm-yyyy',
'autoclose' => true,
'language' => 'id',
'weekStart' => 1,
),'prepend' => '<i class="icon-calendar"></i>'));
?></div>
<div id="un-attend" class="row" style="display:none"><?php echo $form->datepickerRow($model, 'tgl_selesai', array(
'class' => 'span20 input-inline',
'disabled' => 'disabled', //
'options' => array(
'format' => 'dd-mm-yyyy',
'autoclose' => true,
'language' => 'id',
'weekStart' => 1,
),'prepend' => '<i class="icon-calendar"></i>'));
?></div>
I want to make it disable if div attend show block, because its require in my model.
thanks advance