how to update a textfield after dropdown is selected using ajax

how do i update a textfield which is readonly when a value from dropdownlist is selected using ajax…do someone help me




<?php

Yii::app()->clientScript->registerScript(CClientScript::POS_READY, '

$("#dropdown").change(function(){

   $("#textfield").val($("#dropdown").val())

})');

I haven’t tested this code, but I’m pretty sure this will set the value of the textfield with the one of the dropdownlist whenever you change the latter.

Make sure you replace all #IDs with corresponding ones.

thank u…but i need to perform some manipulation before updating the dropdown…need to check the database…what do i do

You have to implement an action to receive ajax request and perform the desired manipulation. You can replace the read-only input value with the output of this action, once ajax has it.

could u explain me further what is the code of my drop down