I am modifying a jQuery autocomplete so that it passes a second term to the search feature to narrow the search. The problem I am having is being able to concatenate the city on to the URL
$(function() {
    var city = $('#city').val();    //get the city value from text field
    var source = 'search.php?city=';  //URL where the search takes place
    //autocomplete
    $(".auto").autocomplete({
    source: source+city ,        //concatenation not working.
    minLength: 1
  });               
}); 
I have tried different ways to concatenate the city name onto the url
$(function() {
    //var city = //$('#city').val();
    var source = 'search.php?city=';
    //autocomplete
    $(".auto").autocomplete({
    source: source+$('#city').val(),
    minLength: 1
  });               
});
I know that the
var city = 'Austin' 
works. I am unsure of the
$('#city').val()
Because if I can hard code it in then the same should work for the function to get the variable from the text field. Right?
The text fields are like this
<form action='' method='post'>
    <p><label>Pharmacy Names : </label><input type='text' name='names' value='' class='auto'></p>
    <p><label>City : </label><input type='text' name='city' id='city' value='' placeholder='Enter City First'></p>
</form>
Even this post Add form value to end of url - Jquery agrees with what I am thinking
This post Get the value in an input text box shows that I am using the correct jquery call to get the textbox value. It just seems like it should be working but it is not.
 
     
    