form auto complete how to restrict results by previous drop down
Using the links suggested from Anil Sagar, I put together this solution using Ajax.

function HolidayAutosXML_carsearch_form($node, &amp;$form_state) {
  $country_list = _get_country_list();
  $form['country'] = array(
    '#type' =&gt; 'select',
    '#title' =&gt; 'Select Country',
    '#description' =&gt; 'Select the country where you want to collect the car',
    '#options' =&gt; $country_list,
    '#ajax' =&gt; array(
      'callback' =&gt; 'update_officename_autocomplete',
      'wrapper' =&gt; 'haofficename',
    ),
  );

  $form['officename'] = array(
'#type' =&gt; 'textfield',
'#title' =&gt; t('Location'),
'#default_value' =&gt; $form_state['office name'],
'#size' =&gt; 20,
'#maxlength' =&gt; 50,
'#description' =&gt; t('Select the location where you want to pick up the car'),
'#attributes' =&gt; NULL,
'#required' =&gt; TRUE,
    '#autocomplete_path' =&gt; 'location-autocomplete',
    '#prefix' =&gt; '&lt;div id="haofficename"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
  );

  if (!empty($form_state['values']['country'])) {
    $form['officename']['#autocomplete_path'] = "location-autocomplete/{$form_state['values']['country']}";
  }

  $form['submit'] = array(
    '#type'=&gt;'submit',
    '#value'=&gt;'Search Now',
    '#submit'=&gt;array('HolidayAutosXML_carsearch_form_submit'),
  );

  return $form;
}



I added an Ajax element to the country drop down, telling it to look for a &lt;div&gt; with an ID equal to "haofficename" and calling a function named update_officename_autocomplete().
I used a prefix and suffix element in the office name element to wrap it in a &lt;div&gt; element with the ID haofficename, which Ajax is going to look for.
update_officename_autocomplete() simply returns the altered office name element of the form. if you look inside the if statement you will see that it is adding to the #autocomplete_path property. So I had to add a second parameter to my autocomplete function. This function now takes $country and $officename.

function location_autocomplete($country,$string){
   $matches = array();
   $result = db_query("select officename from {holidayautos_country_list}        where officename like :keyword and country = :country limit 0, 10",  array(':keyword'=>"%" . db_like($string) . "%",':country'=>$country));
  foreach($result as $row) {
  $matches[$row->officename] = check_plain($row->officename);
  }
  drupal_json_output($matches);
  }


It works like a charm.