Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
112
rated 0 times [  117] [ 5]  / answers: 1 / hits: 30698  / 14 Years ago, tue, august 3, 2010, 12:00:00

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
});
});

More From » jquery

 Answers
13

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



$(function () {
var select = $( #selectType ),
options = select.find( option ),
address = $( #address );

var selectType = options.filter( :selected ).attr( value );
address.autocomplete({
source: ajaxSearchForClientAddress.php?selectType= + selectType,
minLength: 3
});

select.change(function () {
selectType = options.filter( :selected ).attr( value );
address.autocomplete( option, source, ajaxSearchForClientAddress.php?selectType= + selectType );
});
});

[#96031] Sunday, August 1, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jackelyn

Total Points: 303
Total Questions: 103
Total Answers: 102

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
jackelyn questions
Thu, Apr 8, 21, 00:00, 3 Years ago
Sun, Feb 28, 21, 00:00, 3 Years ago
Mon, May 25, 20, 00:00, 4 Years ago
Thu, Apr 30, 20, 00:00, 4 Years ago
;