我正在尝试制作一个 id 搜索器,当您输入正确的 id 时它会执行操作。但是,if 语句始终运行。为什么是这样?
I'm trying to make an id searcher which does a thing when you input the right id. However, the if statement always runs. Why is this?
我正在尝试制作一个 id 搜索器,当您在 google 脚本中输入正确的 id 时,它会执行一些操作。但是,if 语句始终运行。为什么是这样?
代码在这里:
function change()
{
var a = SpreadsheetApp.getActive().getRange("Sheet1!A7")
var b = SpreadsheetApp.getActive().getRange("Sheet1!B7")
var c = SpreadsheetApp.getActive().getRange("Sheet1!C7")
var d = SpreadsheetApp.getActive().getRange("Sheet1!D7")
a.copyTo(SpreadsheetApp.getActive().getRange("Sheet1!M4"))
b.copyTo(SpreadsheetApp.getActive().getRange("Sheet1!N4"))
c.copyTo(SpreadsheetApp.getActive().getRange("Sheet1!O4"))
d.copyTo(SpreadsheetApp.getActive().getRange("Sheet1!P4"))
SpreadsheetApp.getActive().getRange("Sheet1!M4").setBackground("white")
SpreadsheetApp.getActive().getRange("Sheet1!N4").setBackground("white")
SpreadsheetApp.getActive().getRange("Sheet1!O4").setBackground("white")
SpreadsheetApp.getActive().getRange("Sheet1!P4").setBackground("white")
}
function myFunction()
{
var id = SpreadsheetApp.getActiveCell()
var idx = id.getValue()
if (idx = 91360136)
{
change()
}
else { id = "invalid id" }
}
调试器中什么也没有显示。
Google Apps 脚本使用 javascript,其中一个 =
用于将基元或对象分配给变量。使用 ==
进行抽象相等比较或 ===
进行严格相等比较。
改变
if (idx = 91360136) {
到
if (idx === 91360136) {
相关问答
- Using onEdit in Google Spreadsheets to edit cell contents live
- How to set a variable based on other variables
我正在尝试制作一个 id 搜索器,当您在 google 脚本中输入正确的 id 时,它会执行一些操作。但是,if 语句始终运行。为什么是这样? 代码在这里:
function change()
{
var a = SpreadsheetApp.getActive().getRange("Sheet1!A7")
var b = SpreadsheetApp.getActive().getRange("Sheet1!B7")
var c = SpreadsheetApp.getActive().getRange("Sheet1!C7")
var d = SpreadsheetApp.getActive().getRange("Sheet1!D7")
a.copyTo(SpreadsheetApp.getActive().getRange("Sheet1!M4"))
b.copyTo(SpreadsheetApp.getActive().getRange("Sheet1!N4"))
c.copyTo(SpreadsheetApp.getActive().getRange("Sheet1!O4"))
d.copyTo(SpreadsheetApp.getActive().getRange("Sheet1!P4"))
SpreadsheetApp.getActive().getRange("Sheet1!M4").setBackground("white")
SpreadsheetApp.getActive().getRange("Sheet1!N4").setBackground("white")
SpreadsheetApp.getActive().getRange("Sheet1!O4").setBackground("white")
SpreadsheetApp.getActive().getRange("Sheet1!P4").setBackground("white")
}
function myFunction()
{
var id = SpreadsheetApp.getActiveCell()
var idx = id.getValue()
if (idx = 91360136)
{
change()
}
else { id = "invalid id" }
}
调试器中什么也没有显示。
Google Apps 脚本使用 javascript,其中一个 =
用于将基元或对象分配给变量。使用 ==
进行抽象相等比较或 ===
进行严格相等比较。
改变
if (idx = 91360136) {
到
if (idx === 91360136) {
相关问答
- Using onEdit in Google Spreadsheets to edit cell contents live
- How to set a variable based on other variables