假设我有一个包含各种输入的 HTML 文件。根据这些输入,我想发送一封电子邮件,然后显示感谢信息或重定向到感谢页面。
我正在 doGet() 中加载 index.html 文件,如下所示:
function doGet(){
var template = HtmlService.createTemplateFromFile('index');
template.action = ScriptApp.getService().getUrl();
return template.evaluate();
}
Run Code Online (Sandbox Code Playgroud)
在 doPost(e) 函数中添加我需要的实现,将代码部署到 Web 应用程序中,填写表单并提交后,除了最后一点之外,一切似乎都运行良好。我想显示一个输出消息或重定向到一个感谢页面,或者类似的东西,但我看到的只是一个空白页面,那里本来是 HTML 表单。
我试过了:
function doPost(e) {
//all logic
return ContentService.createTextOutput("Thank you");
}
Run Code Online (Sandbox Code Playgroud)
和..
function doPost(e) {
//all logic
return ContentService.createTextOutput(JSON.stringify(e.parameter));
}
Run Code Online (Sandbox Code Playgroud)
和..
function doPost(e) {
//all logic
var htmlBody = "<h1>Thank you.</h1>";
return HtmlService.createHtmlOutput(htmlBody);
}
Run Code Online (Sandbox Code Playgroud)
和..
function doPost(e) {
//all logic
var template = HtmlService.createTemplateFromFile('Thanks');
return template.evaluate();
}
Run Code Online (Sandbox Code Playgroud)
在所有列出的情况下,HTML 表单似乎都消失了,我只能看到一个空白屏幕。
有任何想法吗?
假设我有一个双打数组:
arr = 120,121,118,119,117,123,120
Run Code Online (Sandbox Code Playgroud)
而值x
x = 120
Run Code Online (Sandbox Code Playgroud)
我想得到这个价值
newarr = 120,120,119,121,118,117,123
Run Code Online (Sandbox Code Playgroud)
这是一个新的数组,大小与arr相同,但是值是相对于值x排序的,具有最接近的值(如果它是升序或降序则无关紧要).
任何的想法?
采取这种情况.
我有一个字符串,有时可以在一个变量正整数的" - C(N)"地方结束.(N)
您如何验证字符串是否包含这种子字符串?我认为这是一个有趣的案例,我想看看人们将如何以最整洁和有效的方式解决它.(我正在使用C#)
例如
"ABC - CA" 将返回false
"ABC - C20" 会回归真实