I have the following HTML
<select id="id_cliente">
<option value="1">CLIENTE 1</option>
<option value="2">CLIENTE 2</option>
<option value="3">CLIENTE 3</option>
</select>
I have the following jQuery:
$("#id_cliente").change(function(){
var id_cliente = $("#id_cliente").val();
$.ajax({
type: "POST",
url: "contrato/buscar_cliente",
data: {id_cliente:id_cliente},
success: function(data){
$("#nome").data[nome];
$("#telefone").data[telefone];
$("#email").data[email];
alert(data);
}
});
});
And the search function for the client:
public function buscar_cliente(){
$this->db->where("id_cliente", $_POST['id_cliente']);
print_r($this->db->get("clientes")->row());
}
I know the way I did, it does not work ... My question is:
How do I display the return data within an input? Example: Will return: Name, Phone, Email ...
<input type="text" id="nome" value="">
<input type="text" id="telefone" value="">
<input type="text" id="email" value="">