Say I have an HTML file with various inputs. According to these inputs I would like to send an email and then display a thank you message or redirect to a thank you page.
I am loading the index.html file in the doGet() as below:
function doGet(){
var template = HtmlService.createTemplateFromFile('index');
template.action = ScriptApp.getService().getUrl();
return template.evaluate();
}
After adding the implementation which I require in doPost(e) function, deploying the code into a web app, filling in the form and submitting, everything seems to be working perfectly apart from the last bit. I want to show an output message or redirect to a thank you page, or something of the sort, but all I am seeing is a blank page, where there would have been the HTML form.
I have tried:
function doPost(e) {
//all logic
return ContentService.createTextOutput("Thank you");
}
And..
function doPost(e) {
//all logic
return ContentService.createTextOutput(JSON.stringify(e.parameter));
}
And..
function doPost(e) {
//all logic
var htmlBody = "<h1>Thank you.</h1>";
return HtmlService.createHtmlOutput(htmlBody);
}
And..
function doPost(e) {
//all logic
var template = HtmlService.createTemplateFromFile('Thanks');
return template.evaluate();
}
In all the listed cases the HTML form simply seems to disappear and I can only see a blank screen.
Any ideas?

doPost(e). Note that just because it returns some value doesn't mean that the code which calls the function uses the function's output. - tehhowchactionattribute in the form tag to make a post request, then you must remove that. And you can't have the submit button inside of the form tags. - Alan Wellsgoogle.script.run.withSuccessHandler(yourClientSideFunction).yourServerSideFunction(yourData), then you are simply discarding the return value ofyourServerSideFunction. You have already loaded the webpage - returned by thedoGet()function - and unless you indicate in your client side form submission code that the client HTML should be replaced with some other input HTML, that won't happen. You would do that in your success handler. - tehhowch