1
This is correctly filling the states combobox. How do I proceed now, when selecting the state to combobox of cities referring to the selected state is filled? How to implement the "chargingCities()"?
<?
//seleciona todas as cidades quando o pais nao for o Brasil
$sql = "select distinct loc_cidade, id_local from local where id_pais = '" . $id_pais . "' and loc_cidade <> '' ";
$sql .= " and loc_tipo = 'C' ";
$sql .= " order by loc_cidade";
$local = Consulta($sql, $conexao);
$rs = mysql_query("select distinct loc_uf from local where id_pais = '27' ORDER BY loc_uf ASC");
?>
<select name="estado" id="estado" onChange="carregaCidades()">
<option selected value="estado">Estado</option>
<?php while($reg = mysql_fetch_object($rs)): ?>
<option value="<?php echo $reg->id_local ?>"><?php echo $reg->loc_uf ?></option>
<?php endwhile; ?>
</select>
<div id="load_cidades">
<select name="cidade" id="cidade">
<option value="">Aguardando o estado</option>
</select>
</div>
Here you can try. http://answall.com/questions/87411/selectr-o-pa%C3%Ads-e-traz-o-estado/87417#87417
– Marconi
You need to use ajax, on
onchange()
of the state combo create a function that makes an ajax call to a php file, then take the return and treat. is more or less the idea.– rray