Jquery autocomplete change source -
i have fiddle here
and need availabletags1 source if it's choice1 radio button chosen , availabletags2 if choice2 radio button chosen. , need change dynamically actual user choice.
code:
var availabletags1 = [ "actionscript", "applescript", "asp" ]; var availabletags2 = [ "python", "ruby", "scala", "scheme" ]; $( "#autocomplete" ).autocomplete({ source: availabletags1 }); $('input[name="choice"]').click(function(){ if(this.checked){ if(this.value == "1"){ $( "#autocomplete" ).autocomplete('option', 'source', availabletags1) } else { $( "#autocomplete" ).autocomplete('option', 'source', availabletags2) }
try
$('input[name="choice"]').click(function(){ if(this.checked){ if(this.value == "1"){ $( "#autocomplete" ).autocomplete('option', 'source', availabletags1) } else { $( "#autocomplete" ).autocomplete('option', 'source', availabletags2) } } })
demo: fiddle
Comments
Post a Comment