views:

20

answers:

1

Greetings,

I am using the official Autocomplete jquery widget and am having troubles dynamically changing a variable (selectType) I'm passing via the query string. The variable would change depending upon which option is selected via a select box.

$(function() {
var selectType = $('#selectType option:selected').attr("value");    


$("#selectType").change(function(){
    selectType = $('#selectType option:selected').attr("value");
    alert (selectType);  // alerts the right value for debugging
});

$("#address").autocomplete({
    source: "ajaxSearchForClientAddress.php?selectType="+selectType,
    minLength: 3
}); 
});
+1  A: 

Try actually changing the source option of the autocomplete on the change event.

$(function() {

var selectType = $('#selectType option:selected').attr("value");    
$("#address").autocomplete({
    source: "ajaxSearchForClientAddress.php?selectType="+selectType,
    minLength: 3
});

$("#selectType").change(function(){
    selectType = $('#selectType option:selected').attr("value");
    $("#address").autocomplete('option','source',"ajaxSearchForClientAddress.php?selectType="+selectType);
});

});
PetersenDidIt
Heck yeah, thank you!
Ryan