-2
EDITED
I have 4 selects I called Level:
Level 1 opens Level 2 as each item is selected.
Each Level 1 item opens a specific select (works and uses Jquery)
What I need:
When selecting any item in Level 2, Open the single select Level 3.
And when selecting any item of Level 3, Open select Level 4
Obs: There is no link between items, only open level 3 and 4
And how to hide levels 2, 3 and 4? Show only when the previous one is selected. (for example: Qdo the user enters for the first time only shows Level 1 > selects > shows Level 2 > selects > shows Level 3 > selects > shows Level 4)
I appreciate the alerts and I’m sorry.
$(function(){
$('.hidden').hide();
//Roda OK = nível 1 abre nível 2
$('select[name=nivel1]').change(function(){
var id = $('select[name=nivel1]').val();
$('select[name=nivel2]').empty();
$('select[name=nivel2]').html($('div.nivel2-f' + id).html());
});
//tentei este. Não faz nada - Como fazer??
$('select[name=nivel2]').change(function(){
var id = $('select[name=nivel2]').val();
$('select[name=nivel3]').empty();
$('select[name=nivel3]').html($('div.nivel3-f' + id).html());
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form>
<select name='nivel1' required>
<option value='0'>Selecionar Nivel 1</option>
<option value='1'>texto A</option>
<option value='2'>texto B</option>
</select>
<select name='nivel2'></select>
<div class="hidden nivel2-f1">
<option value='3'>A texto a</option>
<option value='4'>A texto b</option>
</div>
<div class="hidden nivel2-f2">
<option value='5'>B texto a</option>
<option value='6'>B texto b</option>
</div>
<!-- até aqui esta OK = Nível 1 abre Nivel 2 -->
<!-- aqui começa Nível 3 e Nivel 4 (incompleto)-->
<select name='nivel3'></select>
<div class="hidden nivel3-f3">
<option value='7'>AAA</option>
<option value='8'>BBB</option>
</div>
<select name='nivel4'></select>
<div class="hidden nivel4-f4">
<option value='9'>DDD</option>
<option value='10'>EEE</option>
</div>
<button type="submit">Gravar</button>
</form>
as you have not put together a functional example not to know well what you want to do, can explain better? anyway, should not put elements
divwithin theoptions, should always be aselect, theoptionsand close select, same as you did in "level 1"– Ricardo Pontual
If you open Run you will see that the example works at level 1. I want you to select Level 2 Open Level 3. And when you select Level 3 Open Level 4. The original 2 levels with Divs were obtained from a site with Jquery examples (some time ago). But if you have a different example of 4 sequential levels, you could show here?
– Geo