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',
CHtml::listData(cvp_processo::model()->findAll(array('order'=>'pro_numero_processo')),'pro_codigo','pro_numero_processo'),
array(
'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
________
id
value
Table B
________
id
a_id
another_value
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)?