0

I am using a similar technique as was presented in this previously asked question: how to get value entered in UI created with the new HtmlService However, I am seeing inconsistent behavior between web browsers and even on mobile. My problem is in some browsers (Chrome) my 2nd html page is not displaying, however, in Firefox it does. I went so far as to use the same code was was presented by Eric Koleda in the above link. This is what I have:

function doGet(e) {
  var t = HtmlService.createTemplateFromFile('page1.html');
  t.action = ScriptApp.getService().getUrl();
  return t.evaluate();
}

function doPost(e) {
  Logger.log("In doPost = ");
  var t = HtmlService.createTemplateFromFile('page2.html');
  t.name = e.parameter.name;
  t.comment = e.parameter.comment;
  t.screenshot = e.parameter.screenshot;
  return t.evaluate();
}

page1.html

<html>
  <body>
    <h1>Feedback Form</h1>
    <form action="<?= action ?>" method="post">
      Name: <input type="text" name="name" /><br/>
      Comment:<br/>
      <textarea name="comment"></textarea><br/>
      <input type="submit" value="Submit" />
    </form>
  </body>
</html>

page2.html

<html>
  <body>
    <h1>Thanks</h1>
    <p>Thank you for your feedback.</p>
    Name: <?= name ?><br/>
    Comment: <?= comment ?><br/>
  </body>
</html>

Eric's code from his link runs fine in Chrome for me, so I am not sure why I am having this issue. Also, based on Corey G's comment in the above link, I am wondering if I should be using Templated HTML and just use HTML Service only, but Templated HTML seems to be a good fit for my app. Could it be related to my sites or something else? Thanks for your time. Larry King

Community
  • 1
  • 1
Larry King
  • 419
  • 6
  • 19
  • You've got template values in page2.html that are being left blank, e.g. `= action ?>`. Meanwhile, you're setting values that don't appear in the template, `name`, `comment` and `screenshot`. Perhaps you just want to have multiple pages, rather than pass input to a script (which was the subject of your referenced answers). Take a look at [this answer](http://stackoverflow.com/a/16697525/1677912), maybe that's what you need? – Mogsdad Jun 12 '13 at 21:36
  • Thanks Mogsdad. I had the incorrect file for page2.html. I edited this and it is correct now. – Larry King Jun 12 '13 at 22:03
  • Your edited code works for me in Chrome, IE9 and Firefox. It takes a while for the post to come up, but it does eventually do so. – Mogsdad Jun 13 '13 at 02:16
  • Mogsdad and all, this is a long worked issue, https://code.google.com/p/google-apps-script-issues/issues/detail?id=546. – Larry King Jun 17 '13 at 22:00
  • Mogsdad and all, this is a long worked issue, https://code.google.com/p/google-apps-script-issues/issues/detail?id=546. This is my problem exactly. Inserting Google Apps Script in Sites as a gadget and anonymous user logging in to my mapped domain vs. sites.google.com/a/... – Larry King Jun 17 '13 at 22:06
  • I have been able to work around this by using the strategy under the Forms section in [link] (https://developers.google.com/apps-script/guides/html-service-communication). So rather than swapping display of two html files, I am updating a single html file using a success handler. After hearing back from the server-side script, the client-side script updates the innerHTML of an element outside the form. Seems to work OK for a simple case like above. – Larry King Jun 25 '13 at 16:36
  • And then I had one remaining issue, that being my 2nd apps script access permission was still set to myself only rather than anyone, including anonymous! Simple oversight, but painful. – Larry King Jun 26 '13 at 16:26

0 Answers0