I searched how to show/hide columns depending to choice in drop-down list. I wrote this:
function categoriesCriteres() {
var sections = document.getElementById("sections").value;
if (sections == "generaux") {
document.getElementByClassName("generaux").style.display = "block";
} else {
document.getElementByClassName("generaux").style.display = "none";
}
}
<select class="form-control" id="sections" name="sections" onchange="categoriesCriteres()">
<option value="choisir" selected disabled>Choisir</option>
<option id="generaux" value="generaux">Apports généraux</option>
<option id="mineraux" value="mineraux">Minéraux</option>
<option id="vitamines" value="vitamines">Vitamines</option>
<option id="autres" value="autres">Autres</option>
</select>
<div>
<table class="table table-striped" id="nutrition">
<thead>
<tr>
<th>Aliments</th>
<th>Poids</th>
<th class="generaux">Energie kJ</th>
<th class="generaux">Energie kcal</th>
</thead>
<tbody class="text-primary" id="myrecap">
<tr>
<td>blé</td>
<td><strong>150gr</strong></td>
<td class="generaux">energie_kJ</td>
<td class="generaux">energie_kcal</td>
</tr>
<tr>
<td>Total</td>
<td><strong>150 gr</strong></td>
</tr>
</tbody>
</table>
</div>
But nothing happen when I change value on my dropdown-list... I don't understand what's wrong.... Maybe someone can help me ?