dependent dropdown lists

Hello ,

am new to this,working on dependent dropdown,when i select state i want show city names,here am send sample code




<div class="form">


<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'worldareascities-form',

	'enableAjaxValidation'=>false,

)); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<?php echo $form->errorSummary($model); ?>


	<div class="row">

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

			<td><?php echo $form->dropDownList($model,'name', CHtml::listData(worldareascities::model()->findAll(), 'name', 'name'),array('prompt'=>'') ); ?></td>

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

	</div>


	<div class="row">

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

		<td><?php echo $form->dropDownList($model,'stateid', CHtml::listData(worldareascities::model()->findAll(), 'stateid', 'stateid'),array('prompt'=>'') ); ?></td>


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


    </div>

	<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>

	</div>


<?php $this->endWidget(); ?>


</div><!-- form -->




//In view file

<td>

    <?php

    echo

    $form->dropDownList(

            $model, 'country', DropdownHelper::getOptionAll(

                    'Country', 'id', 'name'

            ), array(

        'prompt' => '-Select Country-',

        'onchange' => CHtml::ajax(

                array(

                    'type' => 'POST',

                    'url' => CController::createUrl('dynamicCity'),

                    'update' => '#' . CHtml::activeId($model, 'city')

                )

        )

            )

    );

    ?>

</td>

<td>

    <?php

    echo

    $form->dropDownList(

            $model, 'city', array(), array(

        'onchange' => CHtml::ajax(

                array(

                    'type' => 'POST',

                    'url' => CController::createUrl('dynamicArea'),

                    'update' => '#' . CHtml::activeId($model, 'area')

                )

        )

            )

    );

    ?>

</td>

//My model name is Location

//In controller

public function actionDynamicCity() {

        $country_id = $_POST['Location']['country'];


            $data = Country::model()->findByPk($country_id);

            $i = 0;

            foreach ($data->city as $row) {

                $list[$i]['id'] = $row['id'];

                $list[$i]['city_name'] = $row['city_name'];

                $i++;

            }


            $data = CHtml::listData($list, 'id', 'city_name');

            echo CHtml::tag('option', array('value' => 0), CHtml::encode('-Select City-'), true);


            foreach ($data as $value => $key) {

                echo CHtml::tag('option', array('value' => $value), CHtml::encode($key), true);

            }

    }

hi,

i am new to this framework.

i want to get city name from dropdown if i select state name.

i am having table for city name and state name.