0
Hello!
Through the function below:
success: function( tbl_permissao ) {
obj_permissao = tbl_permissao;
var permissoes = phpUnserialize(obj_permissao.permissoes);
console.log(permissoes);
$.each(permissoes, function (name, valor) {
var $el = $('[name="' + name + '"]'),
type = $el.attr('type');
switch (type) {
case 'checkbox':
$el.prop('checked', true);
break;
case 'radio':
$el.filter('[value="' + valor + '"]').attr('checked', 'checked');
break;
default:
$el.valor(valor);
}
});
obj_form();
ret = true
$('#modal_permissao').modal('show');
$('.modal-title').html('<i class="fa fa-lock "></i> Editar Permissão');
},
More accuracy on the line
var permissoes = phpUnserialize(obj_permissao.permissoes);
console.log(permissoes);
I need it now Mark / Check checkbox type elements, whose valor
is equal to 1.
Using the function below, all checkbox type elements are being marked, so you can help me with this and mark only if value equals 1?
<input name="aCliente" type="checkbox" >
<input name="eCliente" type="checkbox" >
<input name="dCliente" type="checkbox" >
<input name="vCliente" type="checkbox" >
perfect Isac, I just pulled out an equal sign to work.
if (permissoes[chave] == 1)
– Wagner Fillio
@Wagnerfilho, yes it is true in his example comes text instead of number. I had not even noticed
– Isac