0
Hello, I made an example solving your problem!!! Using only the javascript functions getElementById and selectedIndex. To test locally just run the following code in a browser, save it in a file .html and run in your browser.
<!DOCTYPE html>
<html>
<body>
<h3>Pantone</h3> <input type="text" id="pantone" onkeyup="verificarSelect();"/>
<br><br>
<select id="lineatura">
<option value="volvo">SELECIONE</option>
<option value="volvo">52</option>
<option value="saab">42</option>
</select>
<script>
function verificarSelect(){
var lineatura = document.getElementById('lineatura');
var pantone = document.getElementById('pantone');
if(pantone.value != ""){ // Se o valor for preenchido, setar o SELECT para 52
lineatura.selectedIndex = 1; //Indice da opção 52
}
if(pantone.value == ""){ // Caso esteja vazio, selecionar alguma opção
lineatura.selectedIndex = 0;
}
}
</script>
</body>
</html>
To test remotely use: https://codepen.io/anon/pen/LgBBqx
I hope I’ve helped!
Very cool the solution André! I recommend putting a snippet of your code so that users who view your answer can also test and see working.
– João Pedro Schmitz
Thanks @Joãopedroschmitz!
– RXSD
PERFECT ! Exactly what I needed.
– Júlio Ricardo
Great to know it served! Hugs @Júlioricardo
– RXSD