Dear I need your help! I have two drop-down lists that work correctly. One is ciudades and the other comunas, the problem is that I need the comunas list to be dependent on ciudades, for example that when selecting a ciudad from the list, I load the comunas associated with the id of the selected ciudad.
This is my code!
<!-- language: lang-or-tag-here -->
<label>Ciudad:</label><select class="form-control" name="ciudad" required autocomplete="off">
<option value="">Seleccione</option>
<?php foreach($listaciudades as $ciudad):?>
<option value="<?= $ciudad['idciudad']?>"
<?php if ($ciudad == $ciudad['idciudad']) : ?> selected<?php endif; ?>
>
<?= $ciudad['nombre']?>
</option>
<?php endforeach; ?>
</select>
<p><label>Comuna:</label> <select id='comuna' name="comuna" autocomplete="off" required value="<?php echo $comuna; ?>"><?php echo form_error("comuna","<span class='help-block'>","</span>") ?>
<option value="">Seleccione</option>
<?php
foreach($listacomunas as $comuna)
{
echo '<option value="'.$comuna['idcomuna'].'">'.$comuna['nombre'].'</option>';
}
?>
</select>