Problem with Radio Button List

Hi All…

I am working on a page and using radioButtonList for showing three radioButtons and on clicking the radio button an ajax request is fired. Now the problem is that once I select any of the radio button it gets selected and a request is fired but if i click on any of the radio button again that radio button doesn’t get selected .The ajax request is getting fired according to the selected radio button every time but it is not getting shown as selected… Below I am giving the code as well. PLease help

<?php

   &#036;reportType = array();


   &#036;reportType[1] = 'Reports';


   &#036;reportType[2] = 'SMS Alert for critical alarms';


   &#036;reportType[3] = 'Complete IR';


   &#036;select ='';

?>

<div class="form">

<?php $form=$this->beginWidget(‘CActiveForm’, array(

   'id'=&gt;'machine-alert-and-report-details-form',


   'enableAjaxValidation'=&gt;false,

)); ?>

<table border="0" cellpadding="0" cellspacing="0" class="sumInfo difective-info faqCreate">

<tr>

   &lt;td colspan =&quot;3&quot;&gt;&lt;?php echo CHtml::label('Reports*','reports',array()); ?&gt;&lt;/td&gt;

</tr>

<tr>

   &lt;td&gt;&lt;?php echo CHtml::radioButtonList('reports',&#036;select,&#036;reportType,array('ajax'=&gt;array('type'=&gt;'POST','url'=&gt;CController::createUrl('reportDetails/getform'),'update' =&gt;'#reportForm') ,'class' =&gt;'select1','id'=&gt;'reportName','name'=&gt;'reportName'));?&gt;&lt;/td&gt;

</tr>

<tr id ="reportForm"></tr>

</table>

</div>

<?php $this->endWidget(); ?>

Regards

Hi,

try to make like this.




....

echo  CHtml::radioButtonList('reports',$select,$reportType,array('class'  =>'select1','name'=>'reportName'));


Yii::app()->clientScript->registerScript('ajax_loading', '

$(".select1").click(function () {

	$.ajax({

    	type:"post",

    	url: "'. CController::createUrl('reportDetails/getform') .'",

    	data:{"reports": $(this).val() },

    	success:function(data) {

        	$("#reportForm").html(data);

    	}

	});

});

', CClientScript::POS_READY);



Hiii

Thanks for the reply

but i don’t understand what does this has to do with the radio button not getting selected

Regards

The problem is that in generated javascript source code.




jQuery('body').delegate('#reports_0','click',function(){........ return false;});



return false is not need so because of this, second time selection is not seen in radio buttons.

Thank you so much, after hours of searching, here’s the solution.

A little tips if someone is in the same case then me.

If you need to submit all the POST parameter from a form


data:jQuery(this).parents("form").serialize(),

This can help you

‘ajax’ => array(

‘type’ => ‘POST’, //request type

‘url’ => CController::createUrl(’…/…’),

‘update’ => ‘#…’

‘complete’ => 'function(){

$("#loading-model").removeClass(“loading”);}’,

),

‘return’=>true,<----Insert this in your code