6
I have the following HTML:
<select id="faturamento-mes-referencia">
<option value="1">Janeiro</option>
<option value="2">Fevereiro</option>
<option value="3">Março</option>
<option value="4">Abril</option>
<option value="5">Maio</option>
<option value="6">Junho</option>
<option value="7">Julho</option>
<option value="8">Agosto</option>
<option value="9">Setembro</option>
<option value="10">Outubro</option>
<option value="11">Novembro</option>
<option value="12">Dezembro</option>
</select>
And javascript:
var mes = 8;
document.getElementById('faturamento-mes-referencia');
I would like to select the option
that has value="8"
based on my variable that is dynamic and in the case would appear August, in the project use jquery if facilitate.
Taking doubts would like the result so:
<select id="faturamento-mes-referencia">
<option value="1">Janeiro</option>
<option value="2">Fevereiro</option>
<option value="3">Março</option>
<option value="4">Abril</option>
<option value="5">Maio</option>
<option value="6">Junho</option>
<option value="7">Julho</option>
<option value="8" selected>Agosto</option>
<option value="9">Setembro</option>
<option value="10">Outubro</option>
<option value="11">Novembro</option>
<option value="12">Dezembro</option>
</select>
That here would no longer solve your problem?
– Marconi
I guess @Marconi’s answer is what you need then!
– Thiago Santos