Skip to content

Instantly share code, notes, and snippets.

@Sarapulov
Created May 8, 2015 12:26
Show Gist options
  • Select an option

  • Save Sarapulov/b76885af1b7053b34f5e to your computer and use it in GitHub Desktop.

Select an option

Save Sarapulov/b76885af1b7053b34f5e to your computer and use it in GitHub Desktop.
/*
inspired from this sources https://jqueryui.com/autocomplete/#xml
*/
$(function() {
var mydata = [];
$.ajax({
url: "{{YOUR GOOGLE WEB SERVICE URL WHICH RETURNS JSON}}",
dataType: "jsonp",
success: function(data) {
$(data.{{ GOOGLE SHEET NAME }}).each(function() { // MAY VARY DEPENDS ON YOUR JSON OUTCOME
var record = this.NAME + " - " + this.VALUE; // THIS LINE DEPENDS ON YOUR JSON OUTCOME
mydata.push(record);
});
$("#request_custom_fields_24212885").autocomplete({ // USE YOUR TICKET FIELD REFERENCE
source: mydata,
minLength: 0,
select: function(event, ui) {
$("#request_custom_fields_24212885").val( ui.item.value ); // THIS SHOULD SET THE VALUE ONCE YOU MADE A CHOICE
}
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment