我目前有一个Google Web应用程序,用于检查a值(从下拉列表中预定义,因此它将始终位于列中)是否在列中(如果存在),则返回有关该值的信息。我正在尝试对其进行更新,因此,如果在该列(用户输入的值)中找不到该值,它将搜索第二列以查看是否有人输入过该值。一旦找到该用户输入的值,我遇到的问题就是,它会收集与之相邻的单元格的值,然后将其轻拂回客户端HTML javascript,客户端将其视为空值。对于使用预定义的下拉选项的第一部分,它目前工作正常。正确的信息,由于某种原因,它只是客户端,看不到它。对于编码,我有点新手,因此任何人都可以提供的任何帮助将不胜感激。
function sendFleet(e){ // This code sends the dropdown value to the server side
e.preventDefault();
var fleet = document.getElementById("Fleet").value
document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
if(fleet != "Not on this list?"){
var data1 = {
FleetNumber: document.getElementById("Fleet").value,
}
google.script.run.withSuccessHandler(consoleyay)
.sendFleet(data1)
}
else if(fleet == "Not on this list?"){
console.log("right area")
document.getElementById("Rego").innerHTML= "Rego"
document.getElementById("NOLF").style.display=""
document.getElementById("NOLR").style.display=""
document.getElementById("NOLB").style.display=""
document.getElementById("NOLS").style.display=""
document.getElementById("Fleet").style.display="none"
document.getElementById("Rego").style.display="none"
}
}
function SENDFLEET(e){ // This code sends a user entered value to the server.
e.preventDefault();
var fleet = document.getElementById("NOLF").value
document.getElementById('photostatus').innerHTML = "Waiting For Photo.."
var data1 = {
FleetNumber: document.getElementById("NOLF").value,
}
google.script.run.withSuccessHandler(consoleyay)
.sendFleet(data1)
}
function sendFleet(data1){
var Fleet = data1.FleetNumber
var FleetListing = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("FleetListing")
var data2 = FleetListing.getRange(3,3,FleetListing.getLastRow(),1).getValues().reduce(function (a, b) { //flatten the 2D array obtained by .getValues()
return a.concat(b);
});;
var fleetdata = FleetListing.getRange(3,1,FleetListing.getLastRow(),8).getValues()
var Search1 = data2.indexOf(Fleet)
var site = ""
var type = ""
var fleet = ""
var rego = ""
var insidev = ""
var outsidev = ""
var insideb = ""
var outsideb = ""
var search = ""
Logger.log(Search1)
if(Search1 != "-1"){
Logger.log("shouldn't be here")
site = fleetdata[Search1][0]
type = fleetdata[Search1][1]
fleet = fleetdata[Search1][2]
rego = fleetdata[Search1][3]
insidev = fleetdata[Search1][4]
outsidev = fleetdata[Search1][5]
insideb = fleetdata[Search1][6]
outsideb = fleetdata[Search1][7]
search = Search1
}
else if(Search1 == "-1"){
var MTL = SpreadsheetApp.openById("1ufyN6mgzdHXoYbVC6TENcc7V2zGxdQtp0ctaCR-kiEw").getSheetByName("MasterToLocal")
var data3 = MTL.getRange(1,3,MTL.getLastRow(),1).getValues().reduce(function (c, d) { //flatten the 2D array obtained by .getValues()
return c.concat(d);
});;
var fleetdata1 = MTL.getRange(1,1,MTL.getLastRow(),8).getValues()
var Search2 = data3.indexOf(Fleet)
Logger.log("lukes okay")
Logger.log(Fleet)
Logger.log(Search2)
Logger.log(data3)
if(Search2 != "-1"){
Logger.log("Test start")
site = fleetdata1[Search2][0]
Logger.log(site)
type = fleetdata1[Search2][1]
fleet = fleetdata1[Search2][2]
rego = fleetdata1[Search2][3]
insidev = fleetdata1[Search2][4]
outsidev = fleetdata1[Search2][5]
insideb = fleetdata1[Search2][6]
outsideb = fleetdata1[Search2][7]
search = Search2
Logger.log("Test Finish")
}
}
return [site,type,fleet,rego,insidev,outsidev,insideb,outsideb,search]
}
function consoleyay(details){ // this is the code that handles the response from the server.
console.log(details)
var site = document.getElementById("Site").value
console.log(site)
console.log("issues 1")
var Type = document.getElementById("Type").value
console.log("issue 2")
var fleet = details[2]
var rego = details[3]
var inv = details[4]
var outv = details[5]
console.log("before bg")
var inb = details[6]
var outb = details[7]
console.log("after BG")
var Search1 = details[8]
答案 0 :(得分:1)
解决了该问题。我没有使用.getValue,而是使用.getDisplayValue,它将以字符串形式返回日期。