Hello, I have a project, and I need to select other items in a select, but it seems very simple, but I was surprised by the difficulty I'm having in doing it. I have tested so far:
Selecione um carro da lista<br>
<select id="mySelect" onchange="myFunction()">
<option value="Audi">Audi
<option value="BMW">BMW
<option value="Mercedes">Mercedes
<option value="Volvo">Volvo
</select><br><br>
<div id="modelo" style="display:none;">Escolha um modelo<br><select>
<option value="x1">x1</option>
<option value="x2">x2</option>
<option value="x3">x3</option>
<option value="x4">x4</option>
</select></div>
<script>
function myFunction() {
var x = document.getElementById("mySelect").value;
if x.value == ("BMW"){
document.getElementById("modelo").style.display = 'block';
}
}
</script>
Basically, it should, when selected the BMW
tag, change the display style status of the template div, but it does not work.