rodrigo
(Nurmberg)
October 2, 2010, 4:35am
1
Hi,
I wanna change a label when radio button is clicked
This is the view code:
<?php echo CHtml::radioButtonList(‘documento’,‘CPF’,array(‘CPF’=>‘CPF’, ‘CNPJ’=>‘CNPJ’)); ?>
<?php echo $form->labelEx($modelB,‘num’, array(‘label’=>‘RG’)); ?>
<?php echo $form->textField($modelB,‘num’,array(‘size’=>15,‘maxlength’=>15)); ?>
<?php echo $form->error($modelB,‘num’); ?>
When ‘CNPJ’ is selected, the label must change from ‘RG’ to ‘IE’.
Thanks,
Rodrigo
rrbot
(Rob Rhyne)
October 2, 2010, 5:22am
2
I think some simple Javascript is your tool here. Sorry I can’t give more info at the moment, I’m brand new to Yii, but hopefully that gives you an idea of where to start searching.
rodrigo
(Nurmberg)
October 2, 2010, 6:11am
3
Solved adding a id to the label (via htmlOptions) and javascript code (at the end of the view).
Is there a better way of doing this?
<?php echo $form->labelEx($modelB,'num', array('label'=>'RG', 'id'=>'rgLabel')); ?>
<script type="text/javascript">
/*<![CDATA[*/
$(document).ready(function(){
$("#documento_1").click(function () {
if ($(this).is(":checked"))
$("#rgLabel").html("I.E.");
});
$("#documento_0").click(function () {
if ($(this).is(":checked"))
$("#rgLabel").html("RG");
});
});
/*]]>*/
</script>
rodrigo
(Nurmberg)
October 25, 2010, 5:29pm
4
I was able to do the same without using htmlOptions and setting an id for the label
replacing $("#rgLabel ") by $(“label[for=‘RG_num’]”)
Instead of adding the javascript code directly to the view code I used
Yii::app()->clientScript->registerScript()
haseeb2k9
(Hassebashfaq)
December 17, 2012, 2:08pm
5
hi friends can anyone tell me how can i Chang the label of submit button after ajax submitting in yii cgridview
here is my button code;
'btn2' =>array(
'class'=>'CButtonColumn',
'template' => '{AjaxUpdate}',
'buttons'=>array
(
'AjaxUpdate' => array
(
'label'=>'AjaxUpdate',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/update.png', // make sure you have an image
'url'=>'Yii::app()->createUrl("Tasks/AjaxUpdate", array("id"=>$data->id))',
'options' => array( 'ajax' => array('type' => 'get', 'url'=>'js:$(this).attr("href")', 'success' => 'js:function(data) { $.fn.yiiGridView.update("tasks-grid")}')),
),
),
)
plz help me.
thanks in advance