【发布时间】:2016-05-05 20:24:52
【问题描述】:
我正在努力尝试做一些错误提示,以防有人没有输入值。在这种情况下,我检查该值是否为空,并最终检查它是否是一个日期。
所以当这里是倒闭的时候。
1) 运行if语句,如果值为true,则使用字符串参数运行错误提示
if (sheetData[4] === ""){
errorPrompt("Title");
}
2) 使用字符串参数运行以下函数。然后我希望函数将参数传递给 html iframe。
function to open dialog
function errorPrompt(missvar) {
var missVar = "test";
var html = HtmlService.createHtmlOutputFromFile('missingvar')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showModalDialog(html, missVar + ' is Missing please provide ' + missVar + " and try again.");
}
3) 然后该变量应传递给显示为模式对话框的 html 文件。如果字符串等于“Title”,则对话框应为:“Title 丢失。请输入Title 并重试。”
missingvar.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<script>
UI.getElementById("missVar").innerHTML;
</script>
The <var id=missVar></var> is missing. Please enter <var id=missVar></var> and try again.
<input type="button" value="Close"
onclick="google.script.host.close()" />
</body>
</html>
上面的 HTML 显示,但是 missVar 没有显示。有人有什么想法吗?需要注意的是,对话框的标题栏正确显示了变量,但这在 html 之外。
【问题讨论】:
标签: javascript html google-apps-script