0

I'm figuring out about Magento 2 layered navigation. I want to make this navigation with dropdown lists.

I try this code:

<select onchange="setLocation(this.value)">
 <option value=""><?php echo 'Choose an Option...' ?></option>
 <?php foreach ($this->getItems() as $_item): ?>
     <option
        <?php if ($_item->getCount() > 0): ?>
        value="<?php echo $this->urlEscape($_item->getUrl()) ?>"><?php echo $_item->getLabel() ?>
        <?php else: echo '>' . $_item->getLabel() ?>
        <?php endif; ?>
        (<?php echo $_item->getCount() ?>)
    </option>
<?php endforeach ?>
</select>

but I am getting the error "setLocation(this.value) is not defined". If anyone has another option, please let me know.

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

Please add below js code:

function setLocation(value) {
    window.location = value;
}
Amit Saini
  • 575
  • 4
  • 11