Using Javascript only:
HTML
<select id="area" name="area">
<option value="">Selecione</option>
<option value="Informática">Informática</option>
<option value="RH">RH</option>
</select>
<select id="setor" name="setor">
</select>
Javascript (I used Jquery to make it easy):
$(function(){
var setores = {
"Informática": ["Sistemas", "Suporte", "Redes"],
"RH": ["Folha de pagamento", "Benefícios", "Contratações"]
};
$("#area").on('change', function(){
var options = $("#setor");
options.find('option').remove();
if($(this).val() == "") return;
$.each(setores[$(this).val()], function() {
options.append
($("<option />").val(this).text(this)
);
});
});
});
Example in Jsfiddle
In php just take the values of the two select
and concatene.
$_POST['area'].' > '.$_POST['setor']
The values of select
can be done via ajax too
you already have something code done ? if you have pole
– Thiago Friedman
You don’t need Javascript for this. Pure HTML and PHP can handle it.
– MFedatto
Thiago, edit your question and put what you have already done.
– Jéf Bueno