Skip to content

Instantly share code, notes, and snippets.

@dodopok
Created May 3, 2013 16:31
Show Gist options
  • Save dodopok/5510759 to your computer and use it in GitHub Desktop.
Save dodopok/5510759 to your computer and use it in GitHub Desktop.
getEndereco()
function getEndereco(cep,i) {
if(cep !== ""){
$.getScript("https://www.nfservice.com.br/sistema/vendas/clientefornecedor/cep/"+cep, function(){
if (resultadoCEP["resultado"]) {
$("#Endereco"+i+"Logradouro").val(unescape(resultadoCEP["tipo_logradouro"]) + " " + unescape(resultadoCEP["logradouro"]));
$("#Endereco"+i+"Bairro").val(unescape(resultadoCEP["bairro"]));
$("#Endereco"+i+"Cidade").val(unescape(resultadoCEP["cidade"]));
var arg =unescape(resultadoCEP["uf"]);
$("#Endereco"+i+"Uf > option").each(function(){
if($(this).text()==arg) $(this).parent("select").val($(this).val())
})
$("#Endereco"+i+"Numero").focus();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment