Ajax for updating a textField

I know that I can have an Ajax code to update a dropdown, DIVs or any other elements that have innerHTML, like this:

<?php echo CHtml::activeDropDownList($cvp_movimentacao, 'pro_codigo',  



							'empty' => '(Selecione um processo)',

							'ajax' => array(

										'type' 		=> 'GET',

										'url' 		=> array("/{$this->module->id}/movimentacao/carregarListaPi"),

										'data'		=> array('pro_codigo' => 'js:this.value'),

										'update' 	=> '#pi_codigo' 



				); ?>

The code above will update my #pi_codigo element, that is another dropdown, when #pro_codigo changes.

However, now I have a new case. When I select a item from the dropdown, I will have to load one field from the model corresponding to the selected element on an activeTextField on my form.

I’ll try to ilustrate. Suppose that I have to related tables:

Table A




Table B





Then, in my B crud, I will have a dropdown to select an element from A. When I select this item, ajax will must load A.value INTO B.another_value field. But, the actual ‘UPDATE’ item on AJAX can’t do this!

Anyone has some idea about how can I do this (preferencially, with jQuery)?

Just an idea:

If I understood you…

I suggest you to call a find AR method in click/change input event. Call it with Jquery. You can use only Jquery Ajax methods, I have already done it.

"Find all records where id_a equals {element_selected}"

Was it helpfull?

Yes, it is probably what I need.

But, I don’t have any knowledge on jQuery. So, any help will be appreciated :)

Could you post some example?

You should google some examples:


Look at the examples:


Its easy to use.

You can use simple calls:


   type: "POST",

   url: "some.php",

   data: "name=John&location=Boston",

   success: function(msg){

     alert( "Data Saved: " + msg );



Remember that php print do more than output things at the screen, it "sends" data to ajax too.

Thank you very much!! Reputation up ;D