Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

datalist example

// 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);
            });
});
 
PREVIOUS NEXT
Tagged: #datalist
ADD COMMENT
Topic
Name
8+7 =