Senin, Maret 21, 2011

JQuery : Autocomplete extraParams

Case : You want to create an autocomplete that depends on another fields
Solution : Using JQuery Autocomplete with extraParams
Script :


$("#ProvinsiCalonSuami").autocomplete("actions/autocomplete.php?p=provinsi", {
max: 100,
width: 260,
selectFirst: true,
});

$("#KabupatenCalonSuami").autocomplete("actions/autocomplete.php?p=kabupaten", {
max: 100,
width: 260,
selectFirst: true,
extraParams: {
provinsi: function(){
return $('#ProvinsiCalonSuami').val();
}
}
});

$("#KecamatanCalonSuami").autocomplete("actions/autocomplete.php?p=kecamatan", {
max: 100,
width: 260,
selectFirst: true,
extraParams: {
kabupaten: function(){
return $('#KabupatenCalonSuami').val();
}
}
});

$("#KelurahanCalonSuami").autocomplete("actions/autocomplete.php?p=kelurahan", {
max: 100,
width: 260,
selectFirst: true,
extraParams: {
kecamatan: function(){
return $('#KecamatanCalonSuami').val();
}
}
});
Source : http://docs.jquery.com/Plugins/autocomplete

1 comments:

erection pills online viagra mengatakan...

This design is steller! You certainly know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost...HaHa!) Excellent job. I really loved what you had to say, and more than that, how you presented it. Too cool!