I have a question about how to fill in a text input when I change the option in a select, I do this because I want that when I select the patient's name I fill in an input with his phone number, I'm working with codeiniter, bootstrap modals and AJAX, I have tried with the change event of the select but I do not fill the imput with the option of select, I show you how my code is:
select (bootstrap selecpicker):
<div class="col-md-6 col-sm-12">
<label>Paciente</label>
<select class="form-control dropup show-tick" data-live-search="true" id="slc_cliente" style="width: 100%;" title="Selecciona un Paciente" data-width="100%" data-size="3" data-header="Buscar Paciente" data-style="btn-light">
</select>
</div>
the input where I want the phone to be displayed:
<div class="col-md-6 col-sm-12">
<label>Telefono</label>
<div class="input-group">
<input type="text" class="form-control" id="txttelefono" disabled>
<span class="input-group-addon">
<span class="fa fa-phone"></span>
</span>
</div>
</div>
the AJAX of donte I obtain all the information of the patients (id, name, surnames and telephone):
$.post(baseurl + "cCalendar/getClientes",
function (data) {
var clientes = JSON.parse(data);
$.each(clientes, function (i, item) {
$('#slc_cliente').append('<option data-icon="fa fa-user" value="' + item.id_cliente + '">' + item.cliente + '</option>');
});
});
Any ideas on how to do? I'm a super novice with Jquery and Javascript ... Is it the best way to do it or do you suggest another one?
Greetings and thanks for your help in advance.