0

I know that jquery ui use 'term' for filter data.
my problem is : how if i want to use multi field for filter data? city as param1, and name as param2.
here is my autocomplete.

city='Jakarta';
$('#txt_name').autocomplete({
  source:path+'get_person.php?country='+city,
  select:function(event, ui){
    alert(ui.item.name);
  }
});

thank's before.

1 Answer 1

2

Your first parameter will be used as the filter and passed along as 'term'. You can additionally pass other parameters via the URL, assuming they are accessible dynamically like so:

$('#txt_name').autocomplete({
  source:path+'get_person.php?city='+$("#city").val()+"&name="+$("#name").val(),
  select:function(event, ui){
    alert(ui.item.name);
  }
});

Where your form contains two input elements ID'd as 'name' and 'city'.

Then, in your script that performs the query, you'd have access to the filter with $_GET['term'], and access to your city and name variables with $_GET['city'] and $_GET['name'], respectively.

Of course, it looks like you will be searching for a person and filtering by their name? In that case, you don't even have to pass along &name=... as term will contain the filter data you are looking for.

Sign up to request clarification or add additional context in comments.

1 Comment

thank you so much. that great... so, 'term' can be replace with name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.