0
$.getJSON(url, function(json){
$("#pf_endereco").val(json.logradouro);
$("#pf_bairro").val(json.bairro);
$("#cidade").val(json.localidade); <----
$("#estado").val(json.uf); <----
How to put the information of locality and Uf as shown in these arrows (<----
) inside a form when it’s of the type select > option
?
Updating
json.localidade - "MS"
json.localidade - "Campo Grande"
<option value=""></option>
<option value="000001">AC</option>
<option value="000002">AL</option>
<option value="000003">AM</option>
<option value="000004">AP</option>
Update 2
Here are possible methods. http://stackoverflow.com/questions/740195/adding-options-to-a-select-using-jquery-javascript
– Leandro Costa
You want to create new options or mark an existing one as selected?
– bfavaretto
Mark an existing one as selected !!!
– Marcos Vinicius
How are the
value
s of your options? And what comes in json.locality and . Uf?– bfavaretto
bfavaretto
I updated the question with the two information - the feedback and options.– Marcos Vinicius
The ideal would be to return
000001
etc in json.Uf instead ofMS
. And the city equivalent.– bfavaretto
Unfortunately it is an external script and returns the data this way. Probably having to select by
text
!!!– Marcos Vinicius