document.getElementById("codeInput").addEventListener("input",getData);
function getData(){
var code = document.getElementById("codeInput").value;
if(code.length === 5){
google.script.run.withSuccessHandler(view).getTable(code);
}
}
function view(array){
var tbody = document.getElementById("table-body");
var row = document.createElement("tr");
var col1 = document.createElement("td");
col1.textContent = array[0];
var col2 = document.createElement("td");
col2.textContent = array[1];
var col3 = document.createElement("td");
col3.textContent = array[2];
row.appendChild(col1);
row.appendChild(col2);
row.appendChild(col3);
tbody.appendChild(row);
}
function getTable(code){
var url = "https://docs.google.com/spreadsheets/d/1Nh-CCXayaQ8YFuxV76MGnWiAF2rgcxf5bCJwJWvy_-s/edit#gid=0";
var ss = SpreadsheetApp.openByUrl(url);
var ws = ss.getSheetByName("IPP Gol I-III");
var data = ws.getRange(2, 1, ws.getLastRow()-1, 4).getValues();
var codeList = data.map(function(r){return r[1]; });
var submissionList = data.map(function(r){return r[0]; });
var nameList = data.map(function(r){return r[2]; });
var emailList = data.map(function(r){return r[3]; });
var position = codeList.indexOf(code);
var array = [submissionList[position],nameList[position],emailList[position]];
if(position > -1){
return array;
}else{
return 'Unavailable';
}
}
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/0b5d80bb-9218-463c-8802-f93145b92dcfo%40googlegroups.com.