views:

113

answers:

3

Hi,

I have a select box and a textbox, soon I type something I would like to take the value of the select box when autocomplete starts fetching from the server. how could that be possible.

Regards Dixanta Shrestha [email protected]

A: 

I assume you are using jQuery Ajax.

You can specify a custom function to execute on "start", "send", "stop", "success" events of the call, as shown in the events examples in that page:

$.ajax({
    type: "GET",
    url: "...",
    data: { ... },
    success : function(returnedData){
         ...
    },
    error : ...
    ...

To get the value of the select element, you can do:

var myVar=$("#selectElementId").val();
raptors
A: 

you need this plug in installed http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

Funky Dude
A: 

I'm assuming that you are already using the autocomplete plugin (if not, get it). If you want to send the value of the select with the autocomplete request, you can use a function for the extraParams option for the autocomplete plugin to extract the value and send it with.

$('#textbox').autocomplete( '/url', {
    ... other options ...
    extraParams: function() { return $('selectbox').serialize(); },
    ... more options ...
});
tvanfosson