1
I would like to know how to use the index of a select, for example I have select below
function verificartime() {
let time = window.document.getElementsByName("time")
let restime = window.document.getElementById("restime")
// se o time selecionado for o indice[1] então restime.innerHTML="Palmeiras"
// se o time selecionado for o indice[2] então restime.innerHTML="Corinthians" e assim por diante
}
<select name="time">
<option>Selecione seu time</option>
<option value="palmeiras">Palmeiras</option>
<option value="corinthians">Corinthians</option>
<option value="saopaulo">São Paulo</option>
<option value="santos">Santos</option>
</select>
<input type="button" value="Time" onclick="verificartime()">
<div id="restime">
Aqui vai o resultado do select
</div>
I would like to select any team that returns the value in the div
NOTE: I am trying several ways looking on the net but I can’t find a way to perform it,