I have a question regarding forms in google-apps-script. Lets say I have already created a form with a single page and a input box for text. Is it possible to create the follow-up page dynamically, based on the data out of the textbox? Something like:
First Page: insert customer id -> continue -> Second Page: information about the customer.
I know that there are events like onLoad and onSubmit, but there is no onContinue event for example.
Is it possible to create something like that with google-apps-script? What would be the best way to archive such a behavior? B.R.
Using the
UiApp
service, you have onedoGet()
and onedoPost()
function... but here's a way to extend them to support a dynamic multi-part form. (The example code is borrowed from this answer.Your
doGet()
simply builds part1 of your form. In the form, however, you need to identify your form by name, like this:You
doPost()
then, will pass off handling of the post operation to different functions, depending on which form has been submitted. See below. (Also included:reportFormParameters ()
, a default handler that will display all data collected by a form part.)To generate each form part, subsequent form handlers can use the data retrieved in previous parts to dynamically add new Form objects to the ui.
Here is some working code that demonstrates a multiple page form. The code uses a single "hidden" state in a
TextBox
and multipleSubmitButtons
to allow the user to advance forward and backward through the form sequence, as well as to validate the contents of the form. The two extraSubmitButtons
are "rewired" usingClientHandlers
that simply modify the hidden state prior to form submission.