Dependent Control Value To Display And Save To Db

This is tricky question

I have two drop downs one for state and one for city.

I am able to populate state dropdown using the below code

<code>

<?php echo $form->dropDownListRow($model, ‘state_name’, GxHtml::listDataEx(State::model()->findAllAttributes(null, true)),array(‘class’=>‘span3’)); ?>

</code>

Now I want to pass the above selected value as state_id to the below drop down and populate it.

echo $form->dropDownListRow($model, ‘city’, GxHtml::listDataEx(City::model()->findAllAttributes(null, true,‘state_id=1’)),array(‘class’=>‘span3’)); ?>

Is it possible?

I know there is a way create a dependent drop down but I am looking for easy solution to populate and save value to database on form submit

I am new to this technology… any help much appreciated