Contoh datasist

// adding event listener is the best solution to get selected value
// getting input name because datalist value connected with input
<input list="dept_names" id="dept_choose" name="dept_choose" />
 <datalist id="dept_names">             
       <option value="Computer">
       <option value="Information">
       <option value="Management ">
  </datalist>

$(document).ready(function() {
  			// this is the name from ((Input)) with datalist
            var DeptValue = document.getElementsByName('dept_choose')[0];
  			// Adding Event Listener to get the value	
            DeptValue.addEventListener('input', function() {
            	console.log(this.value);
            });
});
Eminem The Programmer