In the snippet below, I have two methods to choose an item: input with datalist and traditional select with options.
The select element keeps the option values hidde
The correct syntax of datalist is like bellow. Also there is no point to have two options with the same name. I took the JavaScript out of the HTML as it should be. ID attribute of the individual options can be replaced with other attribute.
$(function() {
$('input[name=chooseOption]').on('input',function() {
var selectedOption = $('option[value="'+$(this).val()+'"]');
console.log(selectedOption.length ? selectedOption.attr('id') : 'This opiton is not in the list!');
});
});