[ask] about json in combo box


i want to make a combo box when I select the advertiser, the product combo box contents will change (according to the selected combo_box_advertiser).

and textfield job_id will changed to the name of the advertiser selected

I’ve tried using JSON but not successful

help me please…

my code:

Batch /_form

<div class="form">

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



)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

		<div class="row">

		<?php echo $form->labelEx($model,'jobs_id'); ?>

		<?php echo $form->textField($model,'jobs_id',array('size'=>50,'maxlength'=>50)); ?>

		<?php echo $form->error($model,'jobs_id'); ?>



	<div class="row">

		<?php echo $form->labelEx($model,'id_advertiser'); ?>

		<?php echo $form->dropDownList($model,'id_advertiser',CHtml::listData(Advertiser::model()->findAll('deleted IS NULL or deleted <> :deleted',array(':deleted'=>1)), 'id', 'name'),

		array('empty'=>'--Please Choose One--'),




            	'data'=>array('id_advertiser'=>'js:$(\'#Batch_id_advertiser\').val()'),//-->is this correct??


            	'success'=>'function(data) {





		); ?>

		<?php echo $form->error($model,'id_advertiser'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'id_product_category'); ?>

		<?php echo $form->dropDownList($model,'id_product_category',array()); ?>

		<?php echo $form->error($model,'id_product_category'); ?>


<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>


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

</div><!-- form -->



public function actionDodo()


	$id_advertiser = Yii::app()->request->getParam('id_advertiser');





			foreach($data as $value=>$id_product_category)


  			$dropDownA .= CHtml::tag('option', array('value'=>$value),CHtml::encode($id_product_category),true);


			// return data (JSON formatted)

			echo CJSON::encode(array(



			)); Yii::app()->end();




anyone please help me:blink:

Have you checked your JSON output? Is it correct?

how to check the json output?


Using firebug. Or if you use Chrome, I think you can check it under ‘Network’ tab.

i use error console

I get an error

but I did not write this code–> [,‘cache’:false}]

what does this mean?[i][u][b]


i using mozila console

when I select the combobox I run the [action Dodo] but in mozilla writings actionDodo 500 error when on the run

[[10:04:12.253] POST index.php? R = batch/dodo [HTTP/1.0 500 PHP Error 125ms]]

but if i delete echo CJSON:: encode from actionDodo in controller i not get an error

json code in my controller

echo CJSON::encode(array(





what does this mean?[i][b]