Problame In Dropdown List With Autocomplete

hiii…

I need a auto complete text box with drop down list like This Example. Actualy the 3 rd example in this link I need .

For doing this

1st : I add a page named XSuggestAction.php in extensions/actions directory add put the following code:




<?php

class XSuggestAction extends CAction

{

/**

* @var string name of the model class.

*/

public $modelName;

/**

* @var string name of the method of model class that returns data.

*/

public $methodName;

/**

* @var integer maximum number of rows to be returned

*/

public $limit=20;

/**

* Suggests models based on the current user input.

*/

public function run()

{

if(isset($_GET['term'])&&($keyword=trim($_GET['term']))!=='')

{

$suggest=$this->getModel()->{$this->methodName}($keyword,$this->limit,$_GET);

echo CJSON::encode($suggest);

}

}

/**

* @return CActiveRecord

*/

protected function getModel()

{

return CActiveRecord::model($this->modelName);

}

}

?>



[b]

2nd :[/b] Then I add following code in My Controller page :





public function actions()

    {

        return array(

             'suggestProduct'=>array(

             'class'=>'ext.actions.XSuggestAction',

             'modelName'=>'Product',

             'methodName'=>'suggest',

        ));

	}



3rd : Then I add following code in my Model page :




    public function suggest($keyword,$limit=20)

   {

        $models=$this->findAll(array(

           'condition'=>'product_name LIKE :keyword',

           'order'=>'product name',

           'limit'=>$limit,

           'params'=>array(':keyword'=>"%$keyword%")

        ));

       $suggest=array();

           foreach($models as $model) {

             $suggest[] = array(

               

                'product_sale_rate'=>$model->product_sale_rate, // return values from autocomplete

        );

    }

return $suggest;

}



4th : I add the following code in my view page which is _form.php




<?php

$this->widget('zii.widgets.jui.CJuiAutoComplete', array(

    //'model'=>$model,

    //'attribute'=>'name',

    'id'=>'Product_list',

    'name'=>'product_name',

    'source'=>$this->createUrl('request/suggestProduct'),

    'options'=>array(

        'delay'=>300,

        'minLength'=>1,

        'showAnim'=>'fold',

        'select'=>"js:function(event, ui) {

            $('#sale_rate').val(ui.item.product_sale_rate);

            

        }"

    ),

    'htmlOptions'=>array(

        'size'=>'40'

    ),

));


?>






and Add the following code in same page :




	<div class="row" id="sale_rate">

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

		<?php echo $form->textField($model,'product_sale_rate'); ?>

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

	</div>



Now problem is nothing happens when I write some thing in the text field . I want a drop down list of my product which i get from Product model and the price of that particular product shows in the text field whose id is sale_rate .

Plz help me . I Attach my codes With this post . thnx .