I have two selects
, one for employee and one for function, and it is necessary that when an employee is selected the function of that employee is already selected automatically.
This alert
works perfectly, but I need instead to be a code to select a option
of select
of functions according to data-funcao
of the selected employee.
$('#funcionario').on('change', function() {
alert($("option:selected", this).attr('data-funcao'));
});
Employee Select:
<select id="funcionario" name="funcionario">
<option value="..." data-funcao="...">...</option>
...
</select>
Select functions:
<select id="id_mfuncao" name="id_mfuncao">
<option value="...">...</option>
...
</select>
I'm using the select2 jquery plugin, I do not know if it influences anything ...