tags:

views:

1184

answers:

1

Im trying to get the selected value of a 2 radio options (1 & 2)

and pass it into a auto complete extraParams: value

so far i have this

extraParams: { search_option: $('input[name=search_option]:checked').val() },

problem is if the radio is changes the value is not updated.

Any ideas as how i can do this

Thanks

+5  A: 

You need to specify a callback to a function otherwise that value is locked into the autocomplete when you initialize the plugin.

extraParams: {
         search_option : function() { 
                return $('input[name=search_option]:checked').val(); 
         }
}
redsquare
Hey thanks redsquare. I thought it would need to be a function. Having a little trouble with the syntax however as im new to jquery.Getting Error: missing : after property id? How to fix this thanks
John
Can you try the above
redsquare
hmmm, i think because its already inside a function maybe the problem.<script type="text/javascript"> jQuery(function($){ $("#keywords").autocomplete( "/ajax.search.php", { extraParams: { search_option : function() { $('input[name=search_option]:checked').val(); } }, delay:10, minChars:2,Syntax error is gone but o get no value. Any more ideas, thanks?
John
your missing the return
redsquare
jQuery(function($){ $("#keywords").autocomplete( "/ajax.search.php", { extraParams: { search_option : function() { return $('input[name=search_option]:checked').val(); } }, delay:10, minChars:2
redsquare
yeah your right sorry i messed that. Perfect thanks so much :)
John
Anytime, good luck
redsquare