Jump to content

Select option, value from foreach . Bootstrap select


Mijo
 Share

Recommended Posts

Hello everyone, I have Bootstrap select on my website ( https://silviomoreto.github.io/bootstrap-select/examples/ ), im trying to make foreach loop that lists all my brands with url. i want to have possibility that user can search (select brand) and than they go to that specific url, my code is below, can anybody help me with this,? Thank you all.

 <select>
      <?php foreach ( $pages->find('template=single, sort=-created') as $single ):?> 
            <option id="brand-filter" value="<?=$single->url?>" <?=$single->title?>
            </option> 
        <? endforeach; ?>  
   </select>

 

Link to comment
Share on other sites

I would fix your markup, remove the ID from the option since that won't validate (multiple same id).
Also, it looks like you are not closing the opening tag for the option.

in order to have it searchable, you'd need to add

data-live-search="true"

to your select element.

for running an action, you would need to do like an onChange event and then window.location.replace with the value of the selected option..

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...