Created
October 29, 2012 12:34
-
-
Save bruno-barros/3973274 to your computer and use it in GitHub Desktop.
JS: popula cidades 'meucms'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* POPULA COMBOBOX CIDADES | |
* @param UF : string do estado 'RJ' | |
* @param CIDID : ID da cidade | |
* @param obj_target : ID do select da cidade | |
* Ex: <input type="text" name="cep" id="cep" data-uf-id="uf" data-cidade-id="cidade" data-bairro-id="bairro" data-logradouro-id="logradouro" /> | |
*/ | |
function populaCidades(UF, CIDID, obj_target) { | |
myAj = $.ajax({ | |
type: "POST", | |
url: V['site_url'] + "cms/cmsutils/comboCidade/" + UF, | |
dataType: ($.browser.msie) ? "text" : "html", | |
beforeSend: function() { | |
$('.loading-uf').show(); | |
}, | |
success: function(message) { | |
$('.loading-uf').hide(); | |
if (message.length > 0){ | |
$("#"+obj_target).html(message); | |
if(CIDID){ | |
$("#"+obj_target).val(CIDID); | |
} | |
} else { | |
$("#"+obj_target).html('<option>Não existe</option>'); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment