Im using osclass for a local classifieds website and im facing the following problem. I need to import 12 regions and 7000 cities/villages.
In the main.php im using a horizontal search bar with fields search text, categories (dropdown), Regions (dropdown), City (dropdown), Max price(text) and min Price (text)
For the Regions and Cities im using the code in inc.search.php
<?php $aRegions = Region :: newInstance()->listAll();?>
<?php if (count($aRegions) > 0) {?>
<select name="sRegion" id="sRegion">
<option value="">Select a Region</option>
<?php foreach ($aRegions as $region) {?>
<option value="<?php echo $region['s_name'];?>"><?php echo $region['s_name'];?> </option>
<?php } ?>
</select>
<?php } ?>
<?php $aCities = City::newInstance()->listAll(); ?>
<?php if(count($aCities) > 0 ) { ?>
<select name="sCity" id="sCity">
<option value="">Select a city</option>
<?php foreach($aCities as $City) { ?>
<option value="<?php echo $City['s_name'] ; ?>"><?php echo $City['s_name'] ; ?></option>
<?php }?>
</select>
<?php }?>
The problem is that the above code brings all cities when page loads and does not check what region is selected first. That means that the city dropdown will be filled with 7000 cities/villages when page loads.
I tried to remove lines
<?php foreach($aCities as $City) { ?>
<option value="<?php echo $City['s_name'] ; ?>"><?php echo $City['s_name'] ; ?></option>
<?php }?>
so when page loads, the city dropdown is empty but i dont know how to fill the dropdown with cities depend on region select.