I see many examples of using UiApp, but can't figure out how to use HtmlService. For example:
var app = UiApp.getActiveApplication();
...
app.createListBox().setName('list').setId('list')
...
app.getElementById('list').clear();
app.getElementById('list').addItem(...);
With HtmlService, how can I create an HTML file with such a list box? Will I have the same methods?
HtmlService is fundamentally different from UiApp, but aligns very closely with "normal" HTML development, as the app is primarily client based. As a result, the methods you may be familiar with from UiApp have no direct equivalent in HtmlService. In fact, the "service" just provides methods to assemble and display user interfaces, and enables secure communication between them and server-side GAS functions.
Here's a simple example that creates a form with a list that is populated using templated HTML. When submitted, it's POSTed to the
doPost()
function. (NOTE: Publish the script as a web app.)Code.gs
Form.html
Thanks.html