Forum Moderators: open

Message Too Old, No Replies

JQuery autocomplete with dynamic parameters?

Using the autocomplete plugin for JQuery with dynamic parameters

         

roodle

6:09 pm on Oct 8, 2009 (gmt 0)

10+ Year Member



Hi,

I want to use the autocomplete plugin for jquery with 2 parameters that can change according to countries selected on a dropdown menu. Something like the following where db is the database name and c is the country name. This works when the page loads but I need to refresh these values as items are selected:

$(document).ready(
function(){
$("#txt1").autocomplete(
"/handlers/AutocompleteData.ashx",
{
extraParams: {
db: function() { return $('select[name=mydropdownmenu]').val(); },
c: function() { return $('select[name=mydropdownmenu]:selectedIndex').text(); }
}
}
);
}
);

Also the expression select[name=mydropdownmenu]:selectedIndex').text() seems to return all the text from the menu not only that of the selected index. How can I solve that?

Any help will be appreciated.

Thanks in advance.

daveVk

12:19 pm on Oct 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



re 2nd part of question, try
$("select[name=mydropdownmenu] option[@selected]").text();

setExtraParams method may be of use for updating db an c