-2
I have a field that I type the reference code and it already selects automatic select to facilitate the life of the user who already knows the code.
I have this select with two values in a list. I would like to know how I can do a search in select whose search value is at position 1.
$('#inputTurno2').change(function () {
var valSelecionado = $(this).val();
var turno = JSON.parse(valSelecionado);
$('#iputTurno1').val(turno[1])
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" class="form-control pular_inclusa" id="iputTurno1" placeholder="cod">
<select name="turno" class="form-control" id="inputTurno2">
<option value="['', '']">---------</option>
<option value="[1, 1]">Alvorada</option>
<option value="[10, 2]">Federal</option>
</select>
Otherwise I can, select some value in select and it put the value I need in the input.
Yeah, I changed the parse to [0.0], and that worked. with some addition and adjustment that you proposed in the code I was able to solve another part that was unable to handle, which was put an Alert to say that there is no code typed. Thanks so much for the help, I have little time starting in java script still learning.
– gustavo frança