I have the following code:
$.post("php/llenar.php",{opcion: op}, function(data){
$("#valor").html(data);
});
$("#valor").change(function(){
$("#valor option:selected").each(function(){
op = "valor";
valor= $(this).val();
$.post("php/llenar.php",{opcion: op, valor: valor}, function(data){
$("#valor1").val(data.valor);
//$("#cedula").val(data.cedula);
}, "json");
});
});
$valor = mysqli_real_escape_string($con,$_POST['valor']);
if(empty($valor)){
$sql="SELECT codigovar, descripcion FROM valores";
$result=mysqli_query($con, $sql);
$html.="<option valur=''>Escoga una opción</option>";
while($row = mysqli_fetch_array($result))
{
$html.="<option value ='".$row['codigovar']."'>".$row['descripcion']."</option>";
}
}else{
$sql = "SELECT valor FROM valores WHERE codigovar = '$valor'";
$result=mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
echo json_encode(array("valor"=>$row['valor']));
}
<div id="contenedor">
<h1 id="titulo-form"> Asignacion turno de trabajo</h2>
<div id="form">
<form>
<select class="input-100" type = "text" id="tpveh" name="tpveh">
<option value="0">Escoga un tipo de vehiculo</option>
<option value="camioneta">Camioneta</option>
<option value="carry">Carry</option>
<option value="furgon">furgon</option>
<option value="moto">Moto</option>
</select>
<select class="input-100" type = "text" id="placa" name="placa">
</select>
<input class="input-50" type="text" id="mod" name="cc" readonly="readonly">
<input class="input-50" type="text" id="cap" name="nomape" readonly="readonly">
<select class="input-50" type = "text" id="valor" name="valor">
</select>
<input class="input-50" type="text" id="valor1" name="valor1">
<input type = "button" value = " Registrar" class = "btn-enviar" id = "btn-enviar"/>
</form>
</div>
</div>
When checking if the value of the base is pulling me, I realize that the query is doing its job as you can see in the following image.
But you're not assigning the value to the input, I do not know if I'm omitting something.
I would appreciate your help.