I'm currently using this plugin:
https://github.com/devbridge/jQuery-Autocomplete
What I want is that when I selected an option from the name text field I can get that value and put it as a parameter on the address text field where the options in the address field is limited only where name exist in that address.
And same goes when I selected an option from the address field the options in the name field is limited only to names of persons who lives on that address.
Here's my code:
$(document).ready(function(){
var name = '';
var add = '';
$('#name').change(function() {
name = $('#name').val();
});
$('#add').change(function() {
add = $('#add').val();
});
$('#name').devbridgeAutocomplete({
serviceUrl: 'search/name',
minChar: 2,
params: {add: add},
onSelect : function(suggestion) {
$('#name').val(suggestion.value);
}
});
$('#name').devbridgeAutocomplete({
serviceUrl: 'search/address',
minChar: 2,
params: {name: name},
onSelect : function(suggestion) {
$('#name').val(suggestion.value);
}
});
});
I don't know why it's not working, did I do it right or am I doing it all wrong? Please help!
Has anyone else had this problem or know of a solution?