0

I'm an experienced old-school coder (GW-BASIC, anyone?), but just now trying to learn how to use Google Apps Scripts, and I'm completely lost on how to continue my project once the basic Form is created and I open the script editor. The tutorials get a little too advanced too quickly and don't include the basics of what I need.

If someone can assist with a simple "hello world"-type script bound to a Google Form so I can see the syntax to do what I want then it will get me on the right path to work on my project...

So, here's my contrived script: a 3 Section Google Form that asks a person's birth date on the first Section, gives the person's western Zodiac sign on the second Section, then gives the person's Chinese Zodiac sign on the third page. I expect it to look something like this.

Section 1 has a Date question "What is your Birth Date?" I don't know the syntax for saving variables (my first issue), so let's just say to save it as @bd.

The script should perform the following two calculations (LOOKUP formulas following syntax verified by Google Sheets):

LET wz=LOOKUP(VALUE(LEFT(@bd,FIND("/",@bd)-1)*100+LEFT(RIGHT(@bd,LEN(@bd)-FIND("/",@bd)),LEN(@bd)-FIND("/",@bd)-5)),{120;219;321;420;521;621;723;823;923;1023;1122;1222},{"AQUARIUS";"PISCES";"ARIES";"TAURUS";"GEMINI";"CANCER";"LEO";"VIRGO";"LIBRA";"SCORPIO";"SAGITTARIUS";"CAPRICORN"})

LET cz=LOOKUP(MOD(VALUE(RIGHT(@bd,4)),12),{0;1;2;3;4;5;6;7;8;9;10;11;12},{"Monkey","Rooster","Dog","Pig","Rat","Ox","Tiger","Rabbit","Dragon","Snake","Horse","Goat"})

Section 2 has a Title/Description box that says "Your Zodiac sign is @wz"

Section 3 has a Title/Description box that says "Your Chinese Zodiac sign is @cz"

That's it. If someone can produce this simple script then I'll be able to execute my much grander application of Google Scripts.

RamenChef
  • 5,557
  • 11
  • 31
  • 43
  • 1
    If you want a script to run when a Google Form is submitted, then you need to "install" an "On Form Submit" "trigger". A "trigger" is just an event handler, that detects certain events, like editing a spreadsheet, or the time of day, (time trigger) or submitting a Form. An "On Form" submit trigger (event handler) can be installed in a script bound to a Form, a script bound to a spreadsheet, or both. That's probably the first thing that you need to do. [Link to documentation for installable triggers](https://developers.google.com/apps-script/guides/triggers/installable) – Alan Wells Dec 15 '16 at 19:30
  • 1
    The best thing you can do, is to take 5 minutes to read the troubleshooting guide. If you can't debug, then you can't be a programmer. [Link to Apps Script documentation - troubleshooting](https://developers.google.com/apps-script/troubleshooting) – Alan Wells Dec 15 '16 at 19:33
  • Google Apps script is just Javascript with some libraries. I'd look into tutorials for that and you can apply anything that isn't the latest standard (which tutorials won't teach you anyway) in GAS too – Robin Gertenbach Dec 15 '16 at 20:47

1 Answers1

1

Google forms can't work as an interactive application. It can't take an input, process it, and give output to the user. Forms can only take input and save it to a Google spreadsheet.You may have to look at Google app script HTML services.

Anees Hameed
  • 5,916
  • 1
  • 39
  • 43
  • Saving responses to a Google spreadsheet is optional. Reference: https://support.google.com/docs/answer/2917686?hl=en – Rubén Dec 16 '16 at 03:09