jquery - Google spreadsheet Search using javascript -
i'm trying build search option user input id , see result of corresponding id stored in google spreadsheet.
like user input: 1 , see result : nitu 5 , see result : dipon
<input id="id" type="text" placeholder="your id"> <input id="search" type="submit" value="search"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> function displaycontent(json) { var string = "<table>"; var len = json.feed.entry.length; (var i=0; i<len; i++) { var id = json.feed.entry[i].gsx$id.$t; var name = json.feed.entry[i].gsx$name.$t; string += '<tr><td>' + id + '</td><td>' + name + '</td></tr>'; } string += "</table>"; $(string).appendto('body'); } </script> <script src="http://spreadsheets.google.com/feeds/list/1wmvfqeppmquvwtffuzw_3sfst1zbr_aey_xduxz72ng/od6/public/values?alt=json-in-script&callback=displaycontent" type="text/javascript"></script>
i can fetch data google sheet using above code snippet. don't want fetch data @ time. want specific data based on search id.
so how can integrate search feature in javascript?
you can use structured query google spreadsheet api.
so if make get
request proper structured query , relevant data only. in case add sq=id==5
query parameter.
so rather whole data onload , parse afterwads, should make function make proper get
request , fetch data need.
var fetchname = function(id, worksheetid){ var url = 'https://spreadsheets.google.com/feeds/list/'+worksheetid+'/od6/public/values?sq=id='+id+'&alt=json-in-script&callback=?'; $.get( url, function( data ) { //parse , stuff here }); }
hope helps. cheers !!
Comments
Post a Comment