An AJAX HTTP request abnormally terminated in autocomplete textbox
i am using the following code to auto complete the name of the partners (store owners) in a search box in a form to edit a store's detail (not all form elements used are shown here):
the auto_complete call back returns the list of all the partners in the database.
(here one partner owns one store)
you could try and workout something similar:

the submit button links to a submit handler that updates the database.

function partner_store_form($form, &amp;$form_state, $sid = 0) {
      $edit = NULL;  
      if ($sid != 0) {
      $query = db_select('store', 's')
        -&gt;fields('s', array('partner_pid'));
      $query-&gt;leftJoin('partner', 'p', 's.partner_pid = p.pid');
      $query-&gt;condition('s.sid', $sid);
      $query-&gt;addField('p', 'name', 'p_name');
      $edit = $query-&gt;execute()-&gt;fetchObject();
      }
      $form['pid'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Partner Name'),
        '#size' =&gt; 30,
        '#required' =&gt; TRUE,
        '#default_value' =&gt; isset($edit) ? $edit-&gt;p_name . "  [Id:" . $edit-&gt;partner_pid . "]" : '',
        '#maxlength' =&gt; 96,
        '#autocomplete_path' =&gt; 'partner/autocomplete'
      );

      $form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; isset($edit) ? t('Edit') : t('Save'),
        '#submit' =&gt; array('partner_store_form_submit')
      );
    }

    ----------

    $items['partner/autocomplete'] = array(
        'title' =&gt; 'store autocomplete',
        'page callback' =&gt; 'partner_store_autocomplete',
        'access arguments' =&gt; array(CONST_PERM_LIST_PARTNER),
        'type' =&gt; MENU_CALLBACK,
      );

    -----------------

    function partner_store_autocomplete($string) {
      $store = array();
      $query = db_select('partner', 'p');
      $return = $query-&gt;fields('p', array('pid', 'name'))
        -&gt;condition('p.name', '%' . db_like($string) . '%', 'LIKE')
        -&gt;condition('p.remove', 0)
        -&gt;execute();
      foreach ($return as $field) {
        $store[$field-&gt;name . "  [Id:" . $field-&gt;pid . "]"] = check_plain($field-&gt;name);
      }
      if (empty($store)) {
        $store[''] = t('No Such User');
      }
      drupal_json_output($store);
    }