0
I have a script that the user inform the ID fields are completed: name and inactive, if the user has marked the inactive checkbox when registering return the checkbox filled and if you have not checked the checkbox returnit without checking, however my function always returns the checkbox filled
<script type='text/javascript'>
$(document).ready(function(){
$("input[name='id']").blur(function(){
var $nome = $("input[name='nome']");
var $inativo = $("input[name='inativo']");
$.getJSON('function_pes.php',{
id: $( this ).val()
},function( json ){
$nome.val( json.nome );
$inativo.prop('checked', json.inativo );
});
});
});
See if the "inactive" JSON field is coming in quotes, e.g. "true" or "false". prop("checked", json.inactive), it is only checking whether the "inactive" JSON field exists, which is always true, then the check is marked.
– Renato Diniz
I checked in Inspect > Network and my return was this > {"name":"THIAGO SILVA","inactive":"0"} but I have the checkbox return marked, it is really what is happening, could tell me what to do
– user92870