How can I make a page redirection based on the selected option value from a bootstrap select?
Here is the HTML code:
<select class="selectpicker">
<option value="https://example.com/">Home</option>
<option value="https://example.com/page1">Page 1</option>
</select>
And here is the JavaScript code:
$('.selectpicker').selectpicker();
I tried to implement this code for my project, but unfortunately it's not working as expected:
$(document).on('change', '.selectpicker', function(e){
e.preventDefault();
window.location = $(this).val();
});