I was trying code a BMI HTML web by Google app script. However, the result always didn't appear by doPost. My code is below :
Code.gs
function doPost(e){
var h= e.parameter.h;
var w = e.parameter.w;
return
HtmlService.createHtmlOutput("bmi="+w/((h*h)/10000));
}
function doGet(e)
{
var t = HtmlService.createTemplateFromFile('Index');
t.serviceUrl = ScriptApp.getService().getUrl();
return t.evaluate();
}
Index.html
<html>
<body>
<form id="bmiForm" action="<?= serviceUrl ?>" method="post">
<div>height(cm): <input type="text" name="h"/></div>
<div>weight(kg): <input type="text" name="w"/></div>
<input type="submit" value="submit"/>
</form>
</body>
</html>
Look for Answer
consoleand send a log to Stackdriver (regularLoggerwill not be dependable for webapp situations) - tehhowchgoogle.script.run.function()client side API, you might want to look at that. If you are using an Apps Script Web App, sidebar, or dialog box then that might be a better option. https://developers.google.com/apps-script/guides/html/reference/run If your HTML form is not an Apps Script Web App, that is different. If that's the case, then let us know. - Alan Wells