Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get value of datalist javascript

// 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);
            });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: popup alert in flutter 
Javascript :: how to flatten array with reduce in javascript 
Javascript :: get moment date without time 
Javascript :: Another debugger is already connected Rn @ bundle.js:10 
Javascript :: legacy react start 
Javascript :: Add Tailwind CSS to Svelte 
Javascript :: ng generate component in folder 
Javascript :: Convert underscore strings to camel Case 
Javascript :: angular 9 how to get previous state 
Javascript :: go to nextelementsibling javascript 
Javascript :: rn push notification No task registered for key ReactNativeFirebaseMessagingHeadlessTask 
Javascript :: javascript scroll down 
Javascript :: file system replace line js 
Javascript :: vanilla tilt.js 
Javascript :: ajax each function 
Javascript :: json_encode escape 
Javascript :: create parent div javascript 
Javascript :: regex only letters not spaces 
Javascript :: delete package-lock.json command 
Javascript :: javascript append to paragraph 
Javascript :: javascript regex replace all 
Javascript :: javascript div id add class 
Javascript :: How to get unix timestamp from tomorrow nodejs 
Javascript :: axios get error message 
Javascript :: set value to element paragraph in javascript 
Javascript :: node http post 
Javascript :: js go back 
Javascript :: react-native-paper resize switch resize 
Javascript :: .innerhtml 
Javascript :: how to run method in method vue js on load 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =