A functional example, it's up to you to adapt to your case:
Select pulling all the companies from the bank, call an event on onchange that will fill the inputs according to the values searched in the bank:
<select class="select" id="numEmpresa" name="numEmpresa" onchange='empresa(this.value,this.id)' autofocus required>
<option value='-1'>Digite Nº da Empresa</option>
<?php foreach($empresas as $row){ ?>
<option value='<?=$row['num_empresa']?>'>
<?=$row['num_empresa']?> - <?=$row['nm_empresa']?>
</option>
<?php } ?>
</select>
The event onchange company, takes the value of the select and fills the input fees
<!-- Buscar Empresas -->
<script type='text/javascript'>
function empresa(id,select){
$('#honorario').attr("disabled",false);
$.post("autoCompleteSelect.php",{idEsc:id},function(retorno){
$('#honorarios').val(retorno);
}
});
}
</script>
<!-- ./ Buscar Empresas -->
Fill in the input according to the function return:
<input type="text" id="honorarios" name="honorarios" >
Script (autoCompleteSelect.php) that is called within the company event, pulls the value of the input fees from the database and returns to function
$id = (int)$_POST['idEsc']; // id passado pelo select
list($resultados,$quantidade) = $select->selectTable('empresa','valor',NULL,"numero=".$id,NULL);
if($quantidade>0){
foreach ($resultados as $row) {
$dados = str_replace(".",",", $row['valor']);
}
}else{
$dados = '';
}
echo $dados;