How can I add a parameter to an autocomplete with jQueryUI
Dear All,
I am trying to use two autocomplte following this exemple
http://af-design.com/blog/2010/05/12/using-jquery-uis-autocomplete-to-populate-a-form/
First I am extract data to have the Brand of cars (this works)
- // Autocomplete marque
var ac_marques = {
source: 'http://www.website.com/manager/templates/name/xmlhttprequest/autocomplete-marques.php',
minLength: 1,
select:function(event, ui){
$("#h_marque").val(ui.item.id); // That hidden field wil contain the id of the brand car
$("#f_modele").show();
}
};
$(".fmarque").autocomplete(ac_marques);
//FIN Autocomplete marque
When it's done, it display the brand label and in the hidden filed #h_marque contains the id of the brand. Let's say we have the id "32"
Then I want to extract the model of the brand car. For exemple, if I have "Audi", I would like to have only the models of Audo. For the I need to use the value of the hidden field "h_marque"
Here is my code to extarct the model, but I do not know how I can add a parameter to the source.
- // Autocomplete modeles
var ac_modeles = {
source: 'http://www.website.com/manager/templates/name/xmlhttprequest/autocomplete-modeles.php?marque=' + $("#h_marque"), // This does not work
minLength: 1,
select:function(event, ui){
$("#h_modele").val(ui.item.id_modele);
}
};
$(".fmodele").autocomplete(ac_modeles);
//FIN Autocomplete marque
How can I replace this
source: 'http://www.website.com/manager/templates/name/xmlhttprequest/autocomplete-modeles.php?marque=' + $("#h_marque"), // This does not work
How can I properly send the parameter "marque" to the file autocoplete-modeles.php and filter my database to have only the models of the selected brand?
Many thank for your help
Cheers