How to do a Dependent dropdownlist on Search

Hi, i have a dependent dropdownlist


   <?php echo $form->label($model,'City'); ?>

            <?php

        $catOpt=array();

        $cities=Property::model()->findAll("city_id AND status='1'");


            echo $form->dropDownList($model,

                'city_id',

            CHtml::listData($cities,'city.ID','city.name'),array('empty'=>'Select..','options'=>$catOpt, 'ajax' => array(

                    'type'=>'GET', //request type

                    'url'=>CController::createUrl('/Property/Location'), //url to call.

                    'update'=>'#droplocation',

                    'data'=>array('id'=>'js:this.value'))));




            ?>

        <?php echo $form->label($model,'location'); ?>

        <?php // echo CHtml::dropDownList('droplocation','', array()); ?>

        <?php   echo $form->dropDownList($model,'droplocation', array(),$htmlOptions=array('id'=>'droplocation')); ?>




but when i go for the search ,model code


 

if(!empty($_GET['PropertyAdvsearch']['city_id'])) {

            $criteria->compare('city_id',$this->city_id);}


     if($_GET['PropertyAdvsearch']['droplocation']== 'Select') {

            $criteria->compare('city_id',$this->city_id);

              }else {

            $criteria->compare('location_id',$this->droplocation);

        }

doesnt work

Ok so is working now, this is what i done:

Dropdownlist code at the view is the same.

Model:


 if(!empty($_GET['PropertyAdvsearch']['city_id'])) {

            $criteria->compare('city_id',$this->city_id);}


        if(!empty($_GET['PropertyAdvsearch']['droplocation'])) {

            $criteria->compare('location_id',$this->droplocation);}

Controller:


 public function actionLocation()

    {

        $city_id = $_GET['id'];

        $model=new Property();

        $location = $model->findAll("city_id = '".$city_id."' AND status='1'");

        $location = CHtml::listData($location,'location_id','location.name');


        $dropdownLocation=CHtml::tag('option',array('value'=> '' ));        ///[u][b] HAD TO CHANGE THIS SO THAT THE DEFAULT VALUE IS EMPTY ,THIS WAS WHY MY CRITERIA WASNT WORKING [/b][/u]


        foreach($location as $value=>$name)

        {

            $dropdownLocation.=CHtml::tag('option',array('value'=> $value),CHtml::encode($name),true);


        }

        echo  $dropdownLocation;





    }