I'm trying to get a more dynamic autocomplete that will show different results based on the value of a different input within the same form. So far, I have my form:
$form['_search'] = array(
'#type' => 'fieldset',
'#title' => t('Search')
);
$form['_search']['search'] = array(
'#type' => 'textfield',
'#title' => 'Search',
'#autocomplete_path' => 'reports/autocomplete',
'#size' => 30,
);
$form['_search']['submit'] = array(
'#type' => 'submit',
'#value' => t('Search')
);
$form['_search']['where'] = array(
'#type' => 'radios',
'#options' => array(
'choice1' => t('First Choice'),
'choice2' => t('Second Choice'))
);
I came up with a little javascript that changes the autocomplete path based on the radio button chosen:
$('document').ready(
$('@input[@name=where]').bind('change', function() {
$('#edit-search-autocomplete').val('http://my.path.to/reports/autocomplete/'+$('input[@name=where]').val())
}
)
)
It all appears to work just fine (I alerted $(#edit-search-autocomplete).val() and saw what I expected to see), except that the autocomplete doesn't autocomplete anymore. I get a javascript error "jQuery.readyList[i].apply is not a function" in jquery.js when I include my javascript.