I have the following: a form with a customer fields and another appliance field in the database, each device is related to a customer by means of the primary customer key.
what I need: At this moment I already have the completed car running in the client input:
Html:
<div class="col-md-4">
<div class="form-group">
<label for="cliente">Cliente <span style="color:red;">*</span></label>
<input id="cliente1" class="span12 form-control" type="text" name="cliente1" placeholder="Ingrese Cliente" value="" />
<input id="cliente_id" class="span12" type="hidden" name="clientes_id" value="0" />
</div>
Js:
$("#cliente1").autocomplete({
source: "<?php echo base_url(); ?>os/autoCompleteCliente",
minLength: 1,
select: function( event, ui ) {
$("#clientes_id").val(ui.item.id);
}
});
Now, what is the problem? ... I explain:
Up there you see another input from id equivalent to "client_id" (this field fills up when I select an autocomplete option) what I want is that this field here below the name = Ename:
<div class="form-group">
<label for="nombreE">Nombre/Equipo/Marca/Modelo/Nº Serie (Ej. Pc de Juan/Portatil/Sony/SVG31S) </label>
<input name="nombreE" type="text" class="form-control" id="acnombreE" placeholder="Ingrese Nombre, Tipo, Marca, Modelo o Serie" value="">
<input id="aparatosid" class="span12" type="hidden" name="aparatosid" value="" />
</div>
Autocomplete in the same way, but taking into account two things:
but I can not find the way to send those 2 parameters using the jquery autocomplete since jquery only sends me a single parameter named term
This is the js function that I use to autocomplete the field in question, but it throws me all devices that look like what I write in the field, so I need to filter so that only the devices related to the client I selected above:
$("#acnombreE").autocomplete({
source: "<?php echo base_url(); ?>os/autoCompleteaparato
minLength: 1,
select: function( event, ui ) {
$("#aparatosid").val(ui.item.id);
$("#actipoE").val(ui.item.tipoE);
$("#acmarcaE").val(ui.item.marcaE);
$("#acmodeloE").val(ui.item.modeloE);
$("#acn_serieE").val(ui.item.n_serieE);
}
});
Somebody can help me out how I can autocomplete this field and show me suggestions as I write, using the aforementioned field ('client_id') as a second filter,
thank you very much.