[SOLVED] Changing a label on a radio button click


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’.



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.

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">



   $("#documento_1").click(function () {

      if ($(this).is(":checked"))



   $("#documento_0").click(function () {

      if ($(this).is(":checked"))






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


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(


			 'template' => '{AjaxUpdate}',



				 'AjaxUpdate' => array



					 '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