0
I’m a beginner in working with Jquery, and I’m having trouble making a select dynamic function.
By choosing in the first select a value per second select should display only the options with class completed by the value selected in the first select. The same scheme works in the third select in relation to the first.
I used a functional script, but to adapt it it has lost its functionality, but it is written more or less as needed.
<div class="form-group">
<label class="col-sm-3 control-label">Instituição</label>
<div class="col-sm-6">
<select name="instituicao_tur" required="required" class="form-control" id="instituicao_tur">
<option value="0">Selecione</option>
<option value="1"/>Instituição 1
<option value="2"/>Instituição 2
<option value="3"/>Instituição 3
</select>
</div>
</div>
$(document).ready(function() {
$('#instituicao_tur').change(function() {
if ($(this).val() == "0") {
$('.curso_zero').hide();
}
});
$('#instituicao_tur').change(function() {
if ($(this).val() == '1') {
$('.id_cur1').show();
}
});
$('#instituicao_tur').change(function() {
if ($(this).val() == '2') {
$('.id_cur2').show();
}
});
$('#instituicao_tur').change(function() {
if ($(this).val() == '3') {
$('.id_cur3').show();
}
});
});
});
jSFiddle with the base code.
I believe there must be some institutions, many courses and many classes. In this type of scenario, it is interesting to consult the courses and classes available through Ajax.
– Tobias Mesquita
I believe so @bfavaretto. Only the system was done in ASP and with Access bank, so I got it when I tried to do the scheme with Ajax. This question method was to see if it could be done in an alternative way without losing in performance.
– Mauro Alves
you can also use datalist for it. in this case you put on the page all the expected dl, then just toggle them.
– Tobias Mesquita