V
V
Vladimir Zuev2020-06-08 16:10:03
Google Sheets
Vladimir Zuev, 2020-06-08 16:10:03

How can I create an input to receive data from the user?

Hello. Where can I read about creating input for Google Sheets scripts? To get login password etc.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2020-06-08
@vladd56

There are at least a couple of options:
1) Use Browser.inputBox (title, prompt, buttons);

const title   = "Заголовок";
const prompt  = "Сообщение";
const buttons = Browser.Buttons.OK;
  
var retVal1 = Browser.inputBox(title, prompt, buttons);

Returns the string entered by the user.
2) Use SpreadsheetApp.getUi().prompt()
const title   = "Заголовок";
const prompt  = "Сообщение";
const buttons = Browser.Buttons.OK;
  
var retVal2 = SpreadsheetApp.getUi().prompt(title, prompt, buttons);

Returns an object that has a couple of methods:
.getResponseText() - returns the entered text
.getSelectedButton() - returns the pressed button
See how it works in the demo table
There are other options, for example, use a sidebar or a modal window, but you have to write everything there yourself , including scripts, styles, and markup.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question