JSFiddle - React, Tailwind, and code Playground

HTML

<select id="select">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
</select>

<button type="button" id="button">Confirm</button>

JavaScript

let valorImput;

document.getElementById('select').onchange = (e) => {
  valorImput = e.target.value;
  console.log("dropdown onchange console", e.target.value);
};

document.getElementById('button').onclick = (e) => {
	console.log(valorImput);
};