I want to load a value into an input text after selecting a value in a select. I'm loading the normal select. I want to load the input text using javascript. In my model I make a comparison with the id. The data is in the same table.
Java Script:
<script>
var base_url = '<? echo base_url() ?>';
function busca_produtos(id_alug){
$.post(base_url+"parcelas/get_parcelas", {
id_alug : id_alug
}, function(data){
$('#parcelas').html(data);
});
}</script>
My input select working normal:
echo "<select name='aquiller' id='id' class='form-control input-sm' onchange='busca_produtos($(this).val())'>";
My Controller:
public function get_parcelas(){
$parcelas = $this->sindico->get_parcelas();
$option = "<option value=''></option>";
foreach($parcelas -> result() as $linha) {
$option .= "<option value='$linha->id_alug'>$linha->id</option>";
}
echo $option;
}