0

I have created one html template file for show sidebar.

I tried document.getElementById for append dynamic html content but it's give me below error.

ReferenceError: "document" is not defined.

InformationTpl.html

<!DOCTYPE html>
<html>
    <head>
      <base target="_top">
    </head>
    <body>
        <div id="errors"></div>
    </body>
</html>

Code.gs

var getElement = document.getElementById("errors");
    getElement.html("<hr> Hii World !!!</hr>");
var html = HtmlService.createHtmlOutputFromFile('InformationTpl').setTitle("Attention").setWidth(300);
    SpreadsheetApp.getUi().showSidebar(html);

Question : How do I get element from html template and append some dynamic info in this ?

Thanks ! Help will be appreciated.

Jaydeep Mor
  • 1,690
  • 3
  • 21
  • 39
  • Possible duplicate of [Get value of html text box in Apps Script function](https://stackoverflow.com/questions/16525553/get-value-of-html-text-box-in-apps-script-function) – TheMaster Aug 09 '19 at 06:14
  • @TheMaster yes but as in solution uses `click` event and call function. But I don't have any events and using [sidebar](https://developers.google.com/apps-script/reference/base/ui#showsidebaruserinterface) to how template. – Jaydeep Mor Aug 09 '19 at 07:17
  • Where will the dynamic content come from? – TheMaster Aug 09 '19 at 08:14
  • 1
    `document` is in client side. So, you can use `document.getElementById` in the html file – TheMaster Aug 09 '19 at 08:16

0 Answers0