T
T
The Dragger2015-05-01 10:50:42
MySQL
The Dragger, 2015-05-01 10:50:42

How would you recommend doing it?

<?php echo $form->dropDownList($model,'parent_id', CHtml::listData(RefRegion::model()->findAll(), 'id', 'name_ru'), array('empty'=>Yii::t("region", 'Выберите регион'), 'class'=>'span3')); ?>
            <?php echo $form->dropDownList($model,'parent_id', CHtml::listData(RefRegion::model()->findAll(), 'id', 'name_ru'), array('empty'=>Yii::t("region", 'Выберите район'), 'class'=>'span3')); ?>

There are two DropDownLists, for example, if the user selects the Moscow region, then the second should contain all the Moscow districts if Volgograd, etc.
In the database, in one table, all districts and regions are stored names, the regions have parent_id null,
If the Moscow region has id = 14, then its districts have parent_id = 14.
What is the best way to do what I want Ajax or Sql queries?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2015-05-01
@melkij

Ajax or Sql requests?

?! Is it better to go on a trip by car or to the south? How are they related to each other in order to oppose them?

A
avada kedavra, 2015-05-01
@kedavra

region is transferred by ajax, sql query is executed on the server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question