I have a web app like this:
file Code.gs
function doGet(e)
{
var id = e.parameter.id;
if (id == null || id == "")
{
return HtmlService.createHtmlOutputFromFile("InputId");
}
else
{
return HtmlService.createHtmlOutput("Your id is: "+id);
}
}
File InputId.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<form>
<label for="idEmail">Email:</label>
<input type="text" id="idEmail" name="id"><br><br>
<input type="submit" value="Ok">
</form>
</body>
</html>
So the web app works like this:
When user go to: https://script.google.com/macros/s/SomeYadaYada/dev
The page shows the form InputId.html
that asks for user's Id (a.k.a Email), user supposes to enter the Id (e.g YadaYada@gmail.com) then click button Ok.
Expect:
The Url bar redirects to https://script.google.com/macros/s/SomeYadaYada/dev?id=YadaYada@gmail.com
so that the Web app show the text: "Your id is YadaYada@gmail.com".
Result:
The Url bar redirects to https://SomeYadaYada-script.googleusercontent.com/userCodeAppPanel?id=YadaYada@gmail.com
, the Web app, of course, shows nothing.
I have googled this whole morning for solution, but I only found the solution "event.preventDefault();" which doesn't work for me (it only prevent the page reload, while I need the page update the event parameter and reload).
How can I update event parameter with html form submit? Or is there a better approach to solve this problem? I hope I can find the solution that will work also when I embed the web app to Google Sites.