1
Good evening guys, I need a little help, it’s simple but I’m in a jam. I have this combo inside a MODAL, it occurs that the fields of this modal I populate everything by javascript/Json searching the data of a database.
MODAL
<!-- Grid column -->
<div class="col-lg-4 col-md-4">
<div class="md-form form-sm">
<select class="mdb-select colorful-select dropdown-primary" searchable="Busca por nível.." id="frmnivelacesso">
<option value="1"> Master</option>
<option value="2"> Secretária/Recepcionista</option>
<option value="3"> Cirurgião Dentista</option>
</select>
<label for="form8" class="">Nivel de acesso</label>
</div>
</div>
<!-- Grid column -->
JAVASCRIPT
$("#ModalUsuarioEdit").on('shown.bs.modal', function(){
var id = $('#ModalUsuarioEdit').data('id');
$.post('estrutura/usuario.php',{acao:'select',id:id},function(r) {
var ev = jQuery.parseJSON(r);
if (ev.success) {
document.getElementById('frm-imgname').src = 'arquivos/images/' + ev.foto;
var nomecompleto = ev.nome + ' ' + ev.sobrenome;
$("#frm-username").text(nomecompleto);
$("#frmnome").val(ev.nome);
$("#frmsobrenome").val(ev.sobrenome);
$("#frmdtnascimento").val(ev.nascimento);
$("#frmcargo").val(ev.cargo);
$("#frmemail").val(ev.email);
$("#frmtelefone").val(ev.telefone);
$("#frmcro").val(ev.cro);
$("#frmusuario").val(ev.usuario);
$("#frmsenha").val(ev.senha);
$("#frmnivelacesso").val(ev.nivel); // nesse ponto não sei como fazer com que a option da combo fique seleciona
$("#frmnome").focus();
$("#frmsobrenome").focus();
$("#frmdtnascimento").focus();
$("#frmcargo").focus();
$("#frmemail").focus();
$("#frmtelefone").focus();
$("#frmcro").focus();
$("#frmusuario").focus();
$("#frmsenha").focus();
$("#btnfechar").focus();
}
});
It was unclear what your doubt was.
– Phelipe
Yeah, but what’s the doubt?
– hugocsl
Sorry, I forgot to inform, as return from base I want to leave the parameter "Selected" active to the corresponding value. ex: Ev.nivel = 1 then <option value="1" Selected> Master</option>.
– Jefferson Meireles