SO - 18441716

by Arun P Johny

HTML

<input type="radio" name="choice" value="1">choice1
<input type="radio" name="choice" value="2">choice2
<br />
<input id="autocomplete">

JavaScript

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