0

I want to create a html select tag where first option is a input element but it is not working.

  <select name="cars" id="cars">
    <option ><input type="text"></option>
    <option >Saab</option>
    <option >Opel</option>
  </select>

I want to take input from the first option and based on the input change the other option. But can not add the first option as input field. How do i do this?

mahfuj asif
  • 1,691
  • 1
  • 11
  • 32
  • @adiga it's useful when you want to make a search inside the select box – Normal Feb 02 '23 at 06:19
  • It's the requirement. I have no option. It would be much easier if I could put it outside select ta – mahfuj asif Feb 02 '23 at 06:20
  • If you just want search, there are native solutions: [HTML select form with option to enter custom value](https://stackoverflow.com/questions/5650457) – adiga Feb 02 '23 at 06:20
  • 1
    Otherwise, you'd have to use a library: https://select2.org/getting-started/basic-usage – adiga Feb 02 '23 at 06:21

0 Answers0