WordPress Category & Sub-category Dropdown search

Is there any way to create a select search with 2 dropdowns in WordPress – 1 for the Parent Category & 1 For the Sub-Category which changes based on the parent category chosen?

It’s for future projects I just need to know if it’s possible and which route to go with this functionality. I’m aware of the normal WordPress category search and I’ve tried the https://free.searchandfilter.com plugin but this displays all categories even the subs into one dropdown.

It would basically look something like the snippet below:

<!-- Parent Category Select -->
<select>
  <option value="slow">Slow</option>
  <option value="Fast">Fast</option>
  <option value="Fastest">Fastest</option>
</select>


<!-- Sub-Category Select -->
<select>
  <option value="Toyota">Toyota</option> <!-- Slow category -->
  <option value="Subaru">Subaru</option> <!-- Fast category -->
  <option value="mercedes">Mercedes</option> <!-- Slow category -->
  <option value="audi">Audi</option> <!-- Fastest category -->
</select>

<button>
Submit
</button>