Given the code:
var select = document.getElementById('meuSelect');
var input = document.querySelector('input');
select.addEventListener('change', function() {
var option = this.children[this.selectedIndex];
input.value = option.innerHTML;
});
<select id="meuSelect">
<option value="a">Alfa</option>
<option value="b">Beta</option>
<option value="g">Gama</option>
</select>
<input type="text" />
(provided by @Sergio reference )
The code performs the function with a select, the question is: How to get the same result, but with multiple select, where each selected option will be sent to the same input, forming for example a phrase, where each select is a word that make up the phrase Sorry if I was not clear.
For example:
<select id="meuSelect1">
<option value="a">Alfa</option>
<option value="b">Beta</option>
<option value="g">Gama</option>
</select>
<select id="meuSelect2">
<option value="a">Delta</option>
<option value="b">Épsilon</option>
<option value="g">Digama</option>
</select>
<select id="meuSelect3">
<option value="a">Zeta</option>
<option value="b">Eta</option>
<option value="g">Teta</option>
</select>
<input type="text" />
How to proceed in javascript?