0

I am creating a form for users to input information on a Google spreadsheet. They will access the spreadsheet and then click on an image that is linked to a script. When the image is clicked, I want a form to appear. Then I want the input from the form to be accessible in the script.

I am able to create a form but the form does not appear on the sheet. Here is the code thus far for the GS script

function startForm() {
   var form = FormApp.create('myForm');
  var item = form.addCheckboxItem();
  item.setTitle('What would you like to do?');
  item.setChoices([
        item.createChoice('Budget Inquiry'),
        item.createChoice('Add Purchase')
  ]);
  var choices = item.getChoices();
  // then I can respond to the user's choice
}

I would like this simple form to just appear on the google sheet. Any input would be appreciated.

Rubén
  • 34,714
  • 9
  • 70
  • 166
Denise
  • 3
  • 3
  • Welcome to [so]. Please take the [tour] and checkout [ask]. – Rubén Aug 03 '16 at 11:35
  • Possible duplicate of [Single Google Form for multiple Sheets](http://stackoverflow.com/questions/17152120/single-google-form-for-multiple-sheets) – Rubén Aug 04 '16 at 21:00

2 Answers2

1

Instead of creating you own form with script, just go to the insert menu of your spreadsheet and select form. Enter you question and your two choices. Close the form. You will see a form response sheet created in your spreadsheet. Also, a menu item Form will appear on your menu. Then go to the script editor and from the menu select Resources. Select Current Project Triggers and set a new trigger for onFormSubmit. You can then enter a function onFormSubmit to do whatever you want done when the form is submitted getting data from the form response sheet. There is plenty of documentation you can Google.

Ed Nelson
  • 10,015
  • 2
  • 27
  • 29
  • Thanks for your input! I was able to create a form that was connected to the spreadsheet. However, I am having trouble displaying the form on the spreadsheet itself -- maybe this can't be done. I don't want the user to have to click on Form and then click on Go To Live Form. I'd like to have them click on an image on the spreadsheet. I also don't want the form responses to be recorded in the spreadsheet -- that is not needed since they will be inputting different information that I will respond to with the script. Any ideas or help would be appreciated. – Denise Aug 03 '16 at 04:30
  • @ Denise Try this simple sidebar form:https://docs.google.com/spreadsheets/d/1Z5-XAdRRb7ZrHDI-T-hKSu51fGqU3wjfraeIEfc2A5Y/edit?usp=sharing – Ed Nelson Aug 04 '16 at 22:11
  • Hi Ed. Thanks so much. This is exactly what I needed!! This is for a fundraising effort at my daughter's high school (we are raising money for leukemia research). So we all thank you. – Denise Aug 08 '16 at 18:25
  • @Denise Great. If this works for you, please approve my answer. Thanks. – Ed Nelson Aug 08 '16 at 20:01
1

The way in Google Sheets to display external content other than images and Google Drawings is by creating a dialog or sidebar with the related content embeded.

There is a similar question that includes an answer that shows how to do this: Single Google Form for multiple Sheets

Community
  • 1
  • 1
Rubén
  • 34,714
  • 9
  • 70
  • 166
  • Thanks for your suggestion. This would work, but from what I understand I would have to ask a set of questions in different dialog boxes. It would be nice to have a form displayed so that the user can fill it out and then submit it. Is it possible to display a Google form on the spreadsheet -- without forcing the user to click through some menus or work through a set of dialog boxes? Thanks for your input! – Denise Aug 04 '16 at 16:38
  • I updated my answer to include a link to an answered question. – Rubén Aug 04 '16 at 20:59