Colleagues.
I'm trying to get the user to select a value from the select, a corresponding div appears to the value that was selected. Eg: The values of select are:
3, 4, 5, 6, 7, 8 and 12
If the user selects the value 5, a div will appear that contains another select that is multiple, if the user selects other values, another select will appear without being multiple and if you do not select any, keep the select without being multiple as default.
The code I'm trying is this, but when you load the page, no select appears. It's in javascript but I accept suggestions in Jquery:
<script type="text/javascript">
function optionCheck(){
var option = document.getElementById("options").value;
if(option == "5"){
document.getElementById("seriesProfessores").style.visibility
="visible";
document.getElementById("seriesAlunos").style.visibility ="none";
}else if(option == "7" || options == "3" || options == "4" || options == "6" || options == "12"){
document.getElementById("seriesProfessores").style.visibility ="none";
document.getElementById("seriesAlunos").style.visibility ="visible";
}else{
document.getElementById("seriesAlunos").style.visibility ="visible";
}
} </script>
HTML
<select class="form-control select2" id="options" onchange="optionCheck()" name="TipoAcesso" style="width: 100%;">
<option selected="selected">Selecione o tipo de acesso</option>
<option value="3">Administrador da Escola</option>
<option value="7">Aluno</option>
<option value="4">Coordenador</option>
<option value="5">Professor</option>
<option value="8">Responsável</option>
<option value="6">Secretaria</option>
<option value="12">Gerente da Plataforma</option>
</select>
DIV where the select should appear according to the selected value. The selects are within a PHP class which would not be my problem.
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-arrow-circle-right" aria-hidden="true"></i>
</div>
<div id="seriesAlunos" style="visibility:hidden"><?php $tipo = "Alunos"; echo $metodos->visualizarSeries($_SESSION['EscolaSelecionada'],$tipo); ?></div>
<div id="seriesProfessores" style="visibility:hidden"><?php $tipo = "Escolas"; echo $metodos->visualizarSeries($_SESSION['EscolaSelecionada'],$tipo); ?></div>
</div>