Hey there, I am looking to dynamically update the dropdown text with the selected option after a page redirect and reload of the dropdown. Check out my code below:
<div class="sorting-option">
<select id="selectdropdown" class="dropdown-select">
<option value="">Recommended Items</option>
<option value="?sort1desc=F&sort1=Item_NAME">Name (A-Z)</option>
<option value="?sort1desc=T&sort1=Item_NAME">Name (Z-A)</option>
<option value=".f?sort1desc=F&sort1=Item_ONLINECUSTOMERPRICE">Price (Low-High)
</option>
<option value=".f?sort1desc=T&sort1=Item_ONLINECUSTOMERPRICE">Price (High-Low)
</option>
</select>
</div>
Currently, every time I select an option from the dropdown, the page loads but only shows the "Recommended Items" option instead of the one I selected. For example, if I choose "Name (Z-A)", I expect the dropdown text to update accordingly after the page loads.
I've attempted this code to achieve the desired result, though it hasn't worked as expected:
$(document).ready(function () {
$('#selectdropdown').change(function () {
location.href = $(this).val();
$("#selectdropdown option:selected").text();
});
});