Good day, it turns out that I want a page of data update in which I load dependent select with jQuery and Ajax (which I already have it preconfigured in another page where I do it as a new record ~ and the information is load of the db).
I share the view of the page where I add the new information:
<div class="form-group"><!-- desplegar paises -->
<label for="pais">* Pais</label>
<select class="form-control select2" name="pais" id="country">
<option value="">Seleccionar pais</option>
<?php if(!empty($countries)){ foreach($countries as $row){ echo '<option value="'.$row['id_pais'].'">'.$row['nombre_pais'].'</option>';} }else{echo '<option value="">Pais no disponible</option>';}
?>
</select>
</div>
<div class="form-group"><!-- desplegar estados -->
<label for="estado">* Departamento</label>
<select class="form-control select2" name="estado" id="state">
<option value="">Seleccione pais primero</option>
</select>
</div>
<div class="form-group"><!-- desplegar ciudades -->
<label for="municipio">Municipio</label>
<select class="form-control select2" name="municipio" id="city">
<option value="">Seleccione estado primero</option>
</select>
</div>
When I want to update the information on the data update page I have this code, which I add in the value of the input:
<?php echo !empty($post['nombre_primero'])?$post['nombre_primero']:''; ?>
With this I have no problem.
But I can not formulate to load the dependent and not dependent selects in the same way that I do with the input when updating the information.
Send capture to see the result so far:
Thank you in advance.