Seeking assistance for switching style properties of divs based on selection from a select menu. Any guidance would be appreciated!
Here is the code:
The select tag (where I pass the value to the script function):
<div style="float: right; margin-right: 5%; width: auto;">
<select style="border: 3px intset; border-radius: 5px; border-color: #17FFFF;" onchange="showstuff(this.value);">
<optgroup label="Lisboa">
<option value="Picoas">Picoas</option>
<option value="Benfica">Benfica</option>
</optgroup>
<optgroup label="Porto">
<option value="Felgueiras">Felgueiras</option>
<option value="Maia">Maia</option>
</optgroup>
</select>
</div>
The divs with the class names:
<div style="width: 90%; height: 50%; background-color: #09C; overflow: scroll; overflow-x: hidden; margin-bottom: 15%; margin-left: 5%; margin-right: 5%; text-align: left; color: #000; font-size: 60%;">
<div class="Picoas" style="height: 30%; width: 100%; background-color: #CCEAFF; display:none;">
Timberland Picoas<br />
Centro Colombo Morada: Av. Lusíada, Centro Colombo Piso 1, Loja 1.095<br />
1500-392 Lisboa
</div>
<!-- More div elements here with different classes and content -->
</div>
The script and class definitions:
<script type="text/javascript">
function showstuff(element) {
var elementsPicoas = document.getElementsByClassName("Picoas");
elementsPicoas.style.display = element == "Picoas" ? "block" : "none";
// Repeat this block for other classes like Benfica, Felgueiras, Maia
}
</script>
<style>
.Picoas{}
.Felgueiras{}
.Benfica{}
.Maia{}
</style>