*

mheston

  • ***
  • 48 posts
Need help with search function
« on: October 26, 2023, 05:59:09 AM »
My search starts with selecting a location and then the city. If i select Texas and then try to select a city in Texas it tries to show me all cities from all regions. How can i only have it show the cities in Texas.


This is my search code in header.php :


<div class="main-search">
          <div class="cell c1">
            <?php $aRegions = Region::newInstance()->listAll(); ?>
            <?php if(count($aRegions) > 0 ) { ?>
            <select name="sRegion" id="sRegion">
            <option value=""><?php _e('Choose a location...')?></option>
            <?php foreach($aRegions as $region) { ?>
            <option value="<?php echo $region['s_name'] ; ?>"><?php echo $region['s_name'] ; ?></option>
            <?php } ?>
            </select>
            <?php } ?>
          </div>

          <div class="cell c2">
            <?php $aCities = City::newInstance()->listAll(); ?>
            <?php if(count($aCities) > 0 ) { ?>
            <select name="sCity" id="sCity">
            <option value=""><?php _e('Choose a city....')?></option>
            <?php foreach($aCities as $city) { ?>
            <option value="<?php echo $city['s_name'] ; ?>"><?php echo $city['s_name'] ; ?></option>
            <?php } ?>
            </select>
            <?php } ?>
          </div>

          <div class="cell c3">
            <button class="btn btn-primary"><i class="fa fa-search"></i> <span><?php _e("Search", 'sigma');?></span></button>
          </div>
        </div>

*

MB Themes

Re: Need help with search function
« Reply #1 on: October 27, 2023, 07:17:31 AM »
You need ajax that will update cities list after region selection
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots