JBusinessDirectory在搜索表单上拆分类别和子类别

I need to upload about 4000 categories to my JBusinessDirectory. To make it easy for people to search by category, I need to have separate inputs for each category layer. I.e. If I select the parent category as "Parent", in the second input box only the children to that parent would show up.

Ideally, I would like three layers, whereby selection of grandparent in "select box [1]", allows for the selection of that specific grandparents children in "select box [2]" and then "select box [3]" gives the children to that parent would be available. [i.e. [1]Grandparent -> [2]Parent -> [3]Child].

For reference, I am using the category function to implement BISAC codes into my website.

Here is the code on the search module, I am stuck with and need to rejig:

<?php if($params->get('showCategories')){ ?>
<div class="form-field">
<select name="categorySearch" id="categories">
<option value="0"><?php echo JText::_("LNG_ALL_CATEGORIES") ?></option>
<?php foreach($categories as $category){?>
<option value="<?php echo $category->id?>" <?php echo $session->get('categorySearch')==$category->id && $preserve?" selected ":"" ?> ><?php echo $category->name?></option>

<?php if(!empty($category->subcategories)){?>
<?php foreach($category->subcategories as $subCat){?>
<option value="<?php echo $subCat->id?>" <?php  echo $session->get('categorySearch')==$subCat->id && $preserve?" selected ":"" ?> >-- <?php echo $subCat->name?></option>
<?php }?>
<?php }?>

<?php }?>
</select>
</div>
<?php }?>

This can be achieved by selecting the "separate categories" option in the search modules settings. The component will need to be up to date.