3

I can get/access the value of the UI elements using,

e.parameter.elementname or app.getElementById(id) 

if i create UI using UiApps or GUI builder like,

app.add(app.loadComponent("MyGui"));
app.getElementbyId('textbox1').setText("Hi");

If i use, HtmlService.createHtmlOutputFromFile('myPage'); How can i get the values entered in the html form - elements ?

2 Answers 2

6

As an alternative to client-side JavaScript, you can also create simple forms that submit to the doPost() handler which then processes the data. I created a sample script to demonstrate: Run, Source

Sign up to request clarification or add additional context in comments.

2 Comments

why would my doPost() script redirect to an empty page? Even a simple thank you page containing just: <html><body><h1>Thank you!</h1></body></html>, is returning an empty screen?
actually even your example is not redirecting to the Thank you page but a blank page! What should be added to end of the doPost() function? I do not necessarily need a Thank you page, even a message on the same page would do.
5

When using HtmlService you need to rethink your app to be primarily client based not server based. You can (in client-side JavaScript) add a change handler to any element and do something with the value, including calling a server function with google.script.run.myFunction(someValue). See the new user guide here: https://developers.google.com/apps-script/html_service

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.