3
Hello, I have a project, and I need that, when selecting a particular item in a select, appear (or not) other items, seems to me very simple, but I was surprised by the difficulty I’m having in doing so, here’s what 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 brand BMW
, change the display style status of the div model, but it does not work.
+1 and Follows a jsfiddle to complement =]
– Brunno