Dropdown List And Ajax

I have a dropdownlist that is supposed to update a textbox via ajax:

in my view form I have a table that goes like this:









      echo CHtml::ajaxLink(

                 'Update text',

                 array('faturas/ES', 'cod' => 5), // <---- This one works fine

                 array('update' => '#teste')



      echo CHtml::dropDownList('codservico1', '',$listaservicos,


                   'ajax' => array(


                             'url' =>CController::createUrl('faturas/ES'), //<--This one never works. why?


                             'data' => array('cod'=>5),



                   'empty' => 'Escolha o tipo',




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


      <td><div id="teste"><?php echo CHtml::textField('servico1','',array('size'=>25)) ; ?></div></td>

      <td><?php echo CHtml::activeTextField($model,'quantidade1',array('size'=>5)); ?></td>

      <td><?php echo CHtml::activeTextField($model,'preco1',array('size'=>5)); ?></td>

      <td><?php echo CHtml::activeTextField($model,'taxiva1',array('size'=>5)); ?></td>



The ajax link works fine, but when the user chooses some item from the dropdown… nothing happens…

I’m tired and probably making some stupid mistake… Can anyone help me?

Assing id ‘teste’ to the textfield.

So, change this

<td><div id="teste"><?php echo CHtml::textField('servico1','',array('size'=>25)) ; ?></div></td>

to this :

<td><div><?php echo CHtml::textField('servico1','',array('size'=>25, 'id' => 'teste')) ; ?></div></td>

nope… nothing moves…

Try changing this:

'url' =>CController::createUrl('faturas/ES'), //<--This one never works. why?

to this:

'url' =>Yii::app()->request->baseUrl. '/faturas/ES', // maybe wrong controller?

Also, keep the change mentioned in the post above. Previously you would have updated the content of the div rather than the text field.