Show Auto Related Field With Autocomplete

Hi,

I am doing a small application. For that Ihave two table like sles and stores

The sales table looks like this


============

  Sales

============

id

store_id




Stores

=============

id

store_name

store_location

store_code

description



I have done the model and CRUD for both tables. In stores table I have entered some vales as per the table.

Now in sales controller I have rendered both sales and stores. so here my action create looking like this


public function actionCreate()

  {

    $model=new Sales;

    $stores = new Stores;


    // Uncomment the following line if AJAX validation is needed

    // $this->performAjaxValidation($model);


    if(isset($_POST['Sales'], $_POST['Stores']))

    {

      $model->attributes=$_POST['Sales'];

      $stores->attributes=$_POST['Stores'];

      $valid = $model->validate();

      $valid = $stores->validate();

      if($valid)

      {

        $stores->save(false);

        $model->store_id = $stores->getPrimaryKey();

        $model->save(false);

        $this->redirect(array('view','id'=>$model->id));

      }

    }


    $this->render('create',array(

      'model'=>$model,

      'stores'=>$stores,

    ));

  }

and in sales(_form.php) is like this


 <div class="row">

    <?php echo $form->labelEx($stores,'store_name'); ?>

    <?php echo $form->textField($stores,'store_name',array('size'=>60,'maxlength'=>80)); ?>

    <?php echo $form->error($stores,'store_name'); ?>

  </div>


  <div class="row">

    <?php echo $form->labelEx($stores,'store_location'); ?>

    <?php echo $form->textField($stores,'store_location',array('size'=>45,'maxlength'=>45)); ?>

    <?php echo $form->error($stores,'store_location'); ?>

  </div>


  <div class="row">

    <?php echo $form->labelEx($stores,'store_code'); ?>

    <?php echo $form->textField($stores,'store_code',array('size'=>45,'maxlength'=>45)); ?>

    <?php echo $form->error($stores,'store_code'); ?>

  </div>

Now here when I am doing a sales I want that when I will enter one store name by entering keys then it will start to show the related stores names and the store_location and store_code will be autofill. Now can someone kindly tell me how to do this? Any help and suggestions will be appreaciable. Thanks a lot.