'How to change selected option in <select> to shopify
i have some select tags where is options and when i change option, my page refreshs and change url and i need to display what option is currently selected how to do it?
<select
name="brands"
id="brands"
onchange="FILTER.searchParams(event, 'filter.p.vendor')"
>
<option value="{{ collection.url }}">ALL</option>
{% for product_vendor in collection.all_vendors %}
<option {% if option.vendor == product_vendor %} selected="selected" {% endif %} >{{ product_vendor }}</option>
{% endfor %}
</select>
<select
name="category"
id="category"
onchange="FILTER.changePath(event)"
>
<option value="{{ collection.url }}">ALL</option>
{% for collection in collections %}
<option value="{{ collection.url }}">
{{ collection.title }}
</option>
{% endfor %}
</select>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
