There is a list of datalist options. As when clicking on one of the options, insert its value.

<input list="manufacturer" > <datalist id="manufacturer"> <option >1</option> <option>22</option> </datalist> </input><br> 

Found a script that displays for select but not for datalist

  function getManufacturer() { var e = document.getElementById('manufacturer'); console.log(e.options[e.selectedIndex]); document.getElementById('manufacturer'); console.log(document.getElementById('manufacturer')); } 
  • take where? it automatically substitutes the value in the input when clicked. And it’s already very easy to get the value out of it - ThisMan
  • Well get more accurate! - ItsMyLife
  • onchange on input and there it is already possible to get through e.target.value - ThisMan
  • I need to get the value by clicking on <option>. I know that onchange works, but not the way I need - ItsMyLife
  • So how do you need? Update the question so that we would understand what you want to achieve. - Stepan Kasyanenko

0