I am trying to redirect to url when a select is changed and add option text in url query parameter, I have tried this but it seems not working:
$(document).ready(function () {
var url = window.location.href;
$("#select-opt").change(function() {
var option = $(this).find('option:selected');
url = option.data("url");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.1/jquery.min.js"></script>
<select id="select-opt" onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
<option value="test-select1.html">Value 1</option>
<option value="test-select2.html">Value 2</option>
<option value="test-select3.html">Value 3</option>
</select>