Denise
Denise

Reputation: 3

Displaying a Google form on sheets

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.

Upvotes: 0

Views: 1989

Answers (2)

Wicket
Wicket

Reputation: 38435

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

Upvotes: 1

Ed Nelson
Ed Nelson

Reputation: 10259

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.

Upvotes: 1

Related Questions