I have an autocomplete page which gives me a text value, but I want the same text value to open a webpage when hitting enter or selecting the suggested value.
E.g. when I search for india, I type "ind" and "india" automatically comes up, but and I want "india" to open a webpage (like "domain.com/india") when selecting the value or hitting enter
The code is as follows:
<datalist id="countries">
<select>
<select id="dynamic-select">
<option value="www.blahblah.com">Blah</option>
<option value="www.something.com">something</option>
<script>
$('#dynamic-select').bind('change', function () { // bind change event to select
var url = $(this).val(); // get selected value
if (url != '') { // require a URL
window.location = url; // redirect
}
return false;
});
</script>
</datalist>
It pulls out the value but it doesn't open a webpage for me. Can someone help me with this please?